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


/ Published in: PHP
Save to your folder(s)

Search recursive in array


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.