Search value in array object in PHP

NKM picture NKM · Jan 30, 2013 · Viewed 17.7k times · Source
Array
(
    [0] => Array
        (
            [ADADCD] =>       
        )
    [1] => Array
        (
            [ADADCD] => ?     
        )

    [2] => Array
        (
            [ADADCD] => HOSP1 
        )

    [3] => Array
        (
            [ADADCD] => HOSP2 
        )

    [4] => Array
        (
            [ADADCD] => H1    
        )

)

We have an array like this ,I want to search a specific value like HOSP2,What is the process to get the value at index.

Answer

hsz picture hsz · Jan 30, 2013

Just try with array_search

$key = array_search(array('ADADCD' => 'HOSP1'), $inputArray);