Re: More problems...

From: Date: Sat, 18 Nov 2000 16:56:23 +0000
Subject: Re: More problems...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-26065@lists.php.net to get a copy of this message
(VM == "Ville Mattila") ville.mattila@pilotmedia.net writes: VM> I loaded an array for availability code description like this: VM> $avail = array( VM> "A1" => "In store", VM> "AX" => "Not in store (24 hours)", VM> "A" => "Not in store (1-2 days)", VM> "B" => "Not in store (1 week)", VM> "C" => "Not in store (2 weeks)", VM> "D" => "Ei varastossa (3-4 weeks)", VM> "X1" => "Not available"); This is fine. VM> Then I read product data from a file and save it as $prodinfo["Name"], VM> $prodinfo["Avail"] .... VM> VM> Now trying to get description for the code like following, but nothing will be printed out. VM> echo $avail[$prodinfo["Avail"]]; Do this and send us the result: while(list($key,$val) = each($prodinfo)) { print "$key is $val<br>"; } I'm assuming the value of $prodinfo["Avail"] is one of A1, AX, A, B, C, D, or X1 right? If not, it's not going to print anything. VM> I tried this kind of code also: VM> $availc = $prodinfo["Avail"]; VM> echo $availc; // (this works) VM> $availdesc = $avail[$availc]; Try placing the key in quotes an see what you get: $availdesc = $avail["$availc"]; VM> ............................................. VM> Ville Mattila VM> Ikaalinen, Finland -Brian

« previous php.general (#26065) next »