title: Get address multi-dimensional array recursive search php
body: <p>i have the below php search script that will traverse a multidimentional array. when $value is found it will return it, but i wish to return the address as well (considering it is only 2 levels)</p>
  
  <pre><code>function arr_search($array, $line, $lvl=0)
  { 
  
  
  
  // Loops through each element. If element again is array, function is recalled. If not, result is echoed.
  foreach($array as $key=&gt;$value)
  { 
      if(is_array($value))
      {
          arr_search($value, $line); 
      }else{ 
            if(strpos($line, $value))
            echo "found $key: $value\n";
            // return $value; // should return array with [?],[$key],[$value]
      }
  
  }
  
  return false;
  }
  </code></pre>
  
  <p>you can notice that $key is the address of the latest array found. but i want to have the index of the parent array.</p>
  
  <p>array example:</p>
  
  <pre><code>Array
  (
  [0] =&gt; Array
      (
          [0] =&gt; string324
          [1] =&gt; string234
          [2] =&gt; string7567
          [3] =&gt; stringw34
  
      )
  
  [1] =&gt; Array
      (
          [0] =&gt; string4563
          [1] =&gt; string37
  
      )
  
  [2] =&gt; Array
      (
          [0] =&gt; string3735
          [1] =&gt; string3563
          [2] =&gt; string3563
          [3] =&gt; string356
          [4] =&gt; string356
      )
  )
  </code></pre>