Posted By

bigmichiel on 05/06/13


Tagged

array recursive


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

bigmichiel


in_array_r($needle, $haystack, $strict = true);


 / Published in: PHP
 

Search recursive in array

  1. // Recursive in_array functie
  2. function in_array_r($needle, $haystack, $strict = true) {
  3. foreach ($haystack as $item) {
  4. if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {
  5. return true;
  6. }
  7. }
  8. return false;
  9. }

Report this snippet  

You need to login to post a comment.