Req #48391 [Fbk]: strpos accepting arrays
| From: | levim@php.net | Date: | Wed, 16 Apr 2014 19:04:32 +0000 |
| Subject: | Req #48391 [Fbk]: strpos accepting arrays | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185300@lists.php.net to get a copy of this message | ||
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: Feedback
Type: Feature/Change Request
Package: *General Issues
PHP Version: 5.2.9
Block user comment: N
Private report: N
New Comment:
> Code 2 - why isn't this allowed?
It is strictly less useful than the first.
Is this something you are still interested in?
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