Req #75600 [NEW]: strpos($str,$find,$startpos,$endpos)

From: Date: Thu, 30 Nov 2017 14:23:03 +0000
Subject: Req #75600 [NEW]: strpos($str,$find,$startpos,$endpos)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212836@lists.php.net to get a copy of this message
From:             web at houhejie dot cn
Operating system: 
PHP version:      Next Major Version
Package:          *General Issues
Bug Type:         Feature/Change Request
Bug description:strpos($str,$find,$startpos,$endpos)

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 bug report at https://bugs.php.net/bug.php?id=75600&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=75600&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=75600&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=75600&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=75600&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=75600&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=75600&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=75600&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=75600&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=75600&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=75600&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=75600&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=75600&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=75600&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75600&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=75600&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=75600&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=75600&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75600&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=75600&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=75600&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#212836) next »