title: Recursive function: echo works, return doesn't
body: <p>The function aims at finding an item in a range of arrays, and then returning its key.</p>
  
  <p>Problem is that the function doesn't return anything, whereas it would echo the expected result...
  Here is my code:</p>
  
  <pre><code>function listArray($tb, $target){
      foreach($tb as $key =&gt; $value){
          if(is_array($value)){ // current value is an array to explore
              $_SESSION['group'] = $key; // saving the key in case this array contains the searched item
              listArray($value, $target);
          }else {
              if ($target == $value) { // current value is the matching item
                  return $_SESSION['group']; //Trying to return its key
                  break; // I'd like to close foreach as I don't need it anymore
                  }
          }
      }
  }
  </code></pre>
  
  <p>By the way, an other little thing: I'm not used to recursive function, and I didn't find any other solution than using a session variable. But there might be a nicer way of doing it, as I don't use this session variable elsewhere...</p>