note 94885 added to function.in-array

From: Date: Mon, 30 Nov 2009 22:10:16 +0000
Subject: note 94885 added to function.in-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-163437@lists.php.net to get a copy of this message
If you're trying to find out whether or not at least a single value of an array matches a value in your haystack then use "array_intersect" instead of "in_array". $needle = array(1,2); $haystack = array(0,1,2); echo "in_array: ".(int)in_array($needle, $haystack); // returns 0 echo "array_intersect: ".(int)array_intersect((array)$needle, $haystack); // returns 1 ---- Server IP: 208.69.120.55 Probable Submitter: 70.89.93.26 ---- Manual Page -- http://www.php.net/manual/en/function.in-array.php Edit -- https://master.php.net/note/edit/94885 Del: integrated -- https://master.php.net/note/delete/94885/integrated Del: useless -- https://master.php.net/note/delete/94885/useless Del: bad code -- https://master.php.net/note/delete/94885/bad+code Del: spam -- https://master.php.net/note/delete/94885/spam Del: non-english -- https://master.php.net/note/delete/94885/non-english Del: in docs -- https://master.php.net/note/delete/94885/in+docs Del: other reasons-- https://master.php.net/note/delete/94885 Reject -- https://master.php.net/note/reject/94885 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163437) next »