Req #75600 [Opn->Dup]: strpos($str,$find,$startpos,$endpos)

From: Date: Thu, 18 Mar 2021 17:54:23 +0000
Subject: Req #75600 [Opn->Dup]: strpos($str,$find,$startpos,$endpos)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232860@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75600&edit=1

 ID:                 75600
 Updated by:         cmb@php.net
 Reported by:        web at houhejie dot cn
 Summary:            strpos($str,$find,$startpos,$endpos)
-Status:             Open
+Status:             Duplicate
 Type:               Feature/Change Request
-Package:            *General Issues
+Package:            Strings related
 PHP Version:        Next Major Version
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

This is a duplicate of feature request #52124.


Previous Comments:
------------------------------------------------------------------------
[2017-11-30 14:22:57] 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



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=75600&edit=1


Thread (2 messages)

« previous php.bugs (#232860) next »