RE: [PHP] simplifing arrays

From: Date: Tue, 05 Dec 2000 23:53:17 +0000
Subject: RE: [PHP] simplifing arrays
Groups: php.general 
Request: Send a blank email to php-general+get-28786@lists.php.net to get a copy of this message
On your first question, I tried your assignment, and it worked fine. The second one didn't work because missing a dollar sign. $product[${$r["val_1"]}][${$r["val_2"]}] = $r["val_3"]; not $product[{$r["val_1"]}][{$r["val_2"]}] = $r["val_3"]; You might check the version you're on. Anthony -----Original Message----- From: Chris Lee [mailto:lee@mediawaveonline.com] Sent: Tuesday, December 05, 2000 2:21 PM To: php-general@lists.php.net Subject: [PHP] simplifing arrays Is there a way I can do this. I know Im being lazy here. $val_1 = $r["val_1"]; $val_2 = $r["val_2"]; $product[$val_1][$val_2] = $r["val_3"]; I want to write it like this, but this wont work. $product[$r["val_1"]][$r["val_2"]] = $r["val_3"]; I tried this too $product[{$r["val_1"]}][{$r["val_2"]}] = $r["val_3"]; both are a nogo. /---------- on another question, sometimes I want to display the first element of an array, its not allways '0' either. $tmp_array = $some_array; list ($key, $val) = each ($tmp_array); echo "$val <br>\n"; is there a simple way to put that on one nice easy line ? Its such a simple thing. I have to use a tmp_array so that I don't loose my current position in the array, that would happen if I did a reset($some_array). Chris Lee Mediawaveonline.com -- 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 (#28786) next »