Vs: [PHP] More problems...

From: Date: Sat, 18 Nov 2000 17:12:15 +0000
Subject: Vs: [PHP] More problems...
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-26066@lists.php.net to get a copy of this message
Hi Brian & others! This is the code: --- while(list($key,$val) = each($prodinfo)) { print "$key is $val<br>"; } $availc = $prodinfo["Avail"]; $availdesc = $avail["$availc"]; print "*** $availc = $availdesc"; --- And this is the output: --- ID is 15222 Group is 141 Name is Sabena A319 & A321 & B737 Manuf is Price is 170 Avail is D Img is Desc is *** D = --- - Ville ----- Original Message ----- From: Brian Clark <brianj@fusionwerks.com> To: Ville Mattila <ville.mattila@pilotmedia.net> Cc: <php-general@lists.php.net> Sent: Saturday, November 18, 2000 6:56 PM Subject: Re: [PHP] More problems... > > (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 > VM> 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 > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#26066) next »