How to search value in multidimensional array using php

JavaScript Array, search value increase PHP Execution Time connect multiple database display source code save image Export MySQL Database configure mongodb send email from localhost

Now Search value in multidimensional array using php. This is a Best tutorial for Search value in array. I am sharing function for Search value.it’s BestQuestion answer solution for Search value in array.

Also Read : How to show an image preview before upload in Jquery

PHP Interview Questions answers

Here is code for search value in multidimensional array using php

function search_in_array($srchvalue, $array)
{
    if (is_array($array) && count($array) > 0)
    {
        $foundkey = array_search($srchvalue, $array);
        if ($foundkey === FALSE)
        {
            foreach ($array as $key => $value)
            {
                if (is_array($value) && count($value) > 0)
                {
                    $foundkey = search_in_array($srchvalue, $value);
                    if ($foundkey != FALSE)
                        return $foundkey;
                }
            }
        }
        else
            return $foundkey;
    }
}

Leave a Reply