Finding item in an array

    Date: 06/12/06 (PHP Community)    Keywords: no keywords

    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'];
    

    Source: http://community.livejournal.com/php/459223.html

« Sanitizing user data for... || crack base64 encoding? »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home