note 85419 modified in function.in-array by felipe

From: Date: Sun, 07 Sep 2008 14:49:04 +0000
Subject: note 85419 modified in function.in-array by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-144222@lists.php.net to get a copy of this message
This is another implementation of the in_arrayr() function found further down below which didn't really work (it returned upon finding the first nested array and ignoring all other nested arrays). <?php function in_arrayr($needle, $haystack, &$found = false) { foreach ($haystack as $v) { if ($needle == $v) { $found = true; return true; } elseif (is_array($v)) { $this->in_arrayr($needle, $v, $found); } } return $found; } ?> --was-- This is another implementation of the in_arrayr() function found further down below which didn't really work (it returned upon finding the first nested array and ignoring all other nested arrays). function in_arrayr($needle, $haystack, &$found = false) { foreach ($haystack as $v) { if ($needle == $v) { $found = true; return true; } elseif (is_array($v)) { $this->in_arrayr($needle, $v, $found); } } return $found; } http://php.net/manual/en/function.in-array.php

« previous php.notes (#144222) next »