simplifing arrays
| From: | Chris Lee | Date: | Tue, 05 Dec 2000 22:20:58 +0000 |
| Subject: | simplifing arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-28760@lists.php.net to get a copy of this message | ||
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