Re: Getting the array element

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


    $salesperson = array();
while($row=mysql_fetch_array($result)) {

        $salesperson[$row[1]] = '0';

    }

try a var_dump($salesperson); here


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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux