php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #75600 strpos($str,$find,$startpos,$endpos)
Submitted: 2017-11-30 14:22 UTC Modified: 2021-03-18 17:54 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: web at houhejie dot cn Assigned: cmb (profile)
Status: Duplicate Package: Strings related
PHP Version: Next Major Version OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: web at houhejie dot cn
New email:
PHP Version: OS:

 

 [2017-11-30 14:22 UTC] web at houhejie dot cn
Description:
------------
---
From manual page: http://www.php.net/function.strpos
---
hope add $endpos to the function strpos, like: strpos($str,$find,$startpos,$endpos).

then we can efficient to get the result when we need to find pos in a long string, even in a file...

otherwise we need to use substr() additional...

希望在strpos函数中增加一个截止位置参数,像strpos($str,$find,$startpos,$endpos),否则相关需求会调用substr()增加开销

Test script:
---------------
$str="www123xxxxxxxxxxxxxxxxxxxxxxx789yyyyyyyyyyyyyyyyyyy456yyyyyyyyyyyyyyyyy";
$n=strpos($str,'456',5,20);


Expected result:
----------------
$n==false, or $n==-1


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-18 17:54 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Package: *General Issues +Package: Strings related -Assigned To: +Assigned To: cmb
 [2021-03-18 17:54 UTC] cmb@php.net
This is a duplicate of feature request #52124.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC