Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Adam Parker
Added: Apr 19, 2019 12:41 AM
Views: 22
Tags: array php
  1. // Recursive in_array function for use with multidimensional arrays
  2. function in_array_r($needle, $haystack, $strict = false) {
  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. }