Image

Imagecyclotron wrote in Imagephp

Finding item in an array

Hi, I have a complaex array returned from the API
   [0] => Array
        (
            [0] => 1
            [ID] => 1
            [1] => Dave
            [Name] => Dave
            [2] => US English (Male)
            [Language] => US English (Male)
        )

    [1] => Array
        (
            [0] => 2
            [ID] => 2
            [1] => Susan
            [Name] => Susan
            [2] => US English (Female)
            [Language] => US English (Female)
        )

From another function I am given a value such as "Dave", and I have to find and use the value for the ID (For Dave it would be 1)

This doesnt seem to work:

$key = array_search("Dave", $array);
$id = $array[$key][ID];


Any idea how to do this?

SOLVED
foreach ($array as $key => $sub_array) 
	{
		if (array_search('Dave', $sub_array, true))
			{
			$voice_id = $key;
			}
    }
$id = $array[$voice_id]['ID'];