Re: [RFC] Deprecations for PHP 8.4
| From: | Gina P. Banyard | Date: | Wed, 26 Jun 2024 12:14:03 +0000 |
| Subject: | Re: [RFC] Deprecations for PHP 8.4 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-123865@lists.php.net to get a copy of this message | ||
On Wednesday, 26 June 2024 at 06:18, Mike Schinkel <mike@newclarity.net> wrote:
>> https://3v4l.org/RDYFs#v8.3.8
>
> Note those seven use-cases are found in around the first 25 results when searching GitHub for
> "strtok(". I could probably find more if I kept looking:
>
>>
>> https://github.com/search?q=strtok%28+language%3APHP+&type=code
>
>>
>
> Regarding explode($delimiter, $str)[0] — unless it is to be special-cased during compilation
> —it is a really inefficient way to find the substring up to the first character, especially for
> large strings and/or when in a tight loop where the explode is contained in a called function
Then use a regex: https://3v4l.org/SGWL5
Or a combination of strpos and substr.
I'd bet that both of these solutions would use less memory, and I would guess the PCRE one
should also be better for performance (although not benchmarked) as it is highly specialized in that
task.
There are *plenty* of solutions to the specific problem you pose here, and thus many different
solutions more or less appropriate.
Best regards,
Gina P. Banyard
>