Re: Getting the array element
| From: | Jochem Maas | Date: | Thu, 04 May 2006 07:22:48 +0000 |
| Subject: | Re: Getting the array element | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235448@lists.php.net to get a copy of this message | ||
Jonas Rosling wrote:
Hi again all, Here my next PHP newbie question. When I'm building an array as bellow. Is there any way I can get the left element out of the array?the 'left element' is the key.
try a var_dump($salesperson); here$salesperson = array(); while($row=mysql_fetch_array($result)) {$salesperson[$row[1]] = '0';}
If I write: echo $salesperson[$row[3]];echo $row[3];
I get the value. I think you know what I mean?!// an example of looping an array: foreach ($salesperson as $empId => $fullName) { echo "salesperson '{$fullName}' has employee id {$empId}"; }
Thanks // Jonas