php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48391 strpos accepting arrays
Submitted: 2009-05-26 00:00 UTC Modified: 2014-12-30 10:41 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: anon at example dot com Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 5.2.9 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: anon at example dot com
New email:
PHP Version: OS:

 

 [2009-05-26 00:00 UTC] 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'))




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-16 19:03 UTC] levim@php.net
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: *General Issues
 [2014-04-16 19:04 UTC] levim@php.net
> Code 2 - why isn't this allowed?

It is strictly less useful than the first. 

Is this something you are still interested in?
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 18:01:29 2024 UTC