Blog

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.