note 60780 added to function.in-array

From: Date: Mon, 16 Jan 2006 13:07:08 +0000
Subject: note 60780 added to function.in-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-101924@lists.php.net to get a copy of this message
The code in the note below didn't work for me the way i thought it would. I had problems when it enter into the recursive array, if it found the needle it will return true, but the parent in_arrayr would not return true also. so here is my correction to that function <?php function in_arrayr($needle, $haystack) { foreach ($haystack as $value) { if ($needle == $value) return true; elseif (is_array($value)) if (in_arrayr($needle, $value)) return true; } return false; } ?> ---- Submitter IP: 200.24.234.70 ---- Manual Page -- http://www.php.net/manual/en/function.in-array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60780 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60780&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60780&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60780&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60780&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60780&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60780&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60780&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60780&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101924) next »