Array question

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

 



I have a question on how to retrieve the value that corresponds to a
key in an array.

$fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');

		$key = array_search($c, $fruit);
		if ( $key === FALSE )
			$n = $c;
		else
		{
			$n = $fruit[$key];  // how to get the value???
		}

the array_search works ok, but how do I get the value?

all I get back is 'a' or 'b', not 'apple' or 'banana'...

TIA

Gerry

--
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