On Tuesday, 25 June 2024 at 19:06, Mike Schinkel <m...@newclarity.net> wrote:

> strtok()
> =====
> strtok() is found 35k times in GitHub:
>
>> https://github.com/search?q=md5%28+language%3APHP+&type=code
>
> It is a commonly used as a "left part of string up to a character" in 
> addition to its intended use for tokenizing.
>
> I would prefer not deprecated because of BC breakage, but IF it is deprecated 
> I would suggest adding a one-for-one replacement function for the "left part 
> of string up to a character" use-case; maybe `str_left("abc.txt",".")` 
> returning `"abc"`.

For this exact case of extracting a file name without an extension, you should 
really just use:

pathinfo

(

$filepath

, PATHINFO_FILENAME);

But for something more generic, you can just do:
explode($delimiter, $str)[0];

So I really don't see why we would need an "str_left()" function.

Best regards,
Gina P. Banyard

Reply via email to