Array name out of field value with data
| From: | Jonas Rosling | Date: | Mon, 22 May 2006 08:52:11 +0000 |
| Subject: | Array name out of field value with data | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-236612@lists.php.net to get a copy of this message | ||
Not so sure if I've tried to work this out before in this list.
I'm trying to make an array name by a field/row value and assigning values
to it. But I'm having some problems getting it to work.
Is it possible to do this? And if, what am I doing wrong? Or is there any
other way to do it?
while($row=mysql_fetch_array($result)) {
// Checking if variable/array is not declared
if (!$$row[0]) {
// Declaring an empty array by the value of sales person code
$$row[0] = array();
// Current sales person code
$code = $row[0];
// Putting the product name as a key and the price as a value in the array
eval("\$code[\$row[1]] = \"$row[2]\";");
}
}
Thanks