RE: [PHP] simplifing arrays

From: Date: Wed, 06 Dec 2000 00:51:51 +0000
Subject: RE: [PHP] simplifing arrays
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-28797@lists.php.net to get a copy of this message
Well all be darned your 100% right it did work. You know I dont have a clue what I was doing wrong. he, wierd. Thanks for pointing that out :) Chris Lee Mediawaveonline.com On Tue, 5 Dec 2000, Anthony Martin wrote: > 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 > >

« previous php.general (#28797) next »