Req #78821 [NEW]: strbrk should accept a $length parameter

From: Date: Sat, 16 Nov 2019 00:00:26 +0000
Subject: Req #78821 [NEW]: strbrk should accept a $length parameter
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223738@lists.php.net to get a copy of this message
From: jerry at jmweb dot net Operating system: n/a PHP version: Irrelevant Package: Strings related Bug Type: Feature/Change Request Bug description:strbrk should accept a $length parameter Description: ------------ Sometimes we just need to know if a single character, among a list of characters, exists in a string. strbrk() is almost what is needed but instead it returns a substring of the original starting from the first occurrence. Admittedly, I am not a C person but inspecting the source code indicates that this feature should be trivial. Here is what I propose the new signature should be: strpbrk ( string $haystack , string $char_list [, int $length ] ) : string; If $length is given and is positive, the string returned will contain at most $length characters. If I follow correctly, "RETURN_STRINGL" ends up calling "zend_string_init" which accepts a "len" parameter as its second argument. How difficult would it be to add this feature? https://github.com/php/php-src/blob/93ba3abe63cd339c52cf5774e948bb35d8e73049/ext/standard/string.c#L6078 -- Edit bug report at https://bugs.php.net/bug.php?id=78821&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78821&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78821&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78821&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78821&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78821&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78821&r=support Expected behavior: https://bugs.php.net/fix.php?id=78821&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78821&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78821&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78821&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78821&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78821&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78821&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78821&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78821&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78821&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78821&r=mysqlcfg

« previous php.bugs (#223738) next »