Search Results

Search found 1 results on 1 pages for '106691756905536410593'.

Page 1/1 | 1 

  • Find key of parent in array / PHP

    - by 106691756905536410593
    Perhaps someone can help me out with this one: I'm using a basic search function to find an array deep within an array. The problem is, once that array is found, I'd also like to return it's parent key. Is there a PHP function that can determine the parent key of an array? Below is an example of the Search Function... Ideally I'd like to return the array that is found, as well as it's parent key. function search($array, $key, $value){ $results = array(); if (is_array($array)){ if ($array[$key] == $value){ $results[] = $array; } foreach ($array as $subarray){ $results = array_merge($results, search($subarray, $key, $value)); } } return $results; }

    Read the article

1