Req #48391 [Opn->Fbk]: strpos accepting arrays
Edit report at https://bugs.php.net/bug.php?id=48391&edit=1
ID: 48391
Updated by: levim@php.net
Reported by: anon at example dot com
Summary: strpos accepting arrays
-Status: Open
+Status: Feedback
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
PHP Version: 5.2.9
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2009-05-26 00:00:36] anon at example dot com
Description:
------------
I think strpos would be greatly improved if the needle could be an
array - much like preg_match, but without needing the complication of
regex.
The only way around this atm is a foreach loop.
Reproduce code:
---------------
Code 1 - currently
foreach(array('searchterm1', 'searchterm2') as $needle)
if(strpos($haystack, $needle) !== FALSE)
return strpos($haystack, $needle);
Code 2 - why isn't this allowed?
strpos($haystack, array('searchterm1', 'searchterm2'))
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=48391&edit=1
Thread (4 messages)