Welcome! Log In Create A New Profile

Advanced

[PHP-DEV] Proposal: Please consider introducing a new function |str_cut| to make fast cutting for a string

Posted by 張俊芝 
Hello.

I'd like to suggest PHP introduce a new function |str_cut| to make fast cutting of a string.



If the user wants to cut a large string to a still-very-large string(say, cutting a 1KB string from a larger string),
|str_cut| would be a far more efficient alternative solution than |substr|:


str_cut($str, 1024) vs $str = substr($str, 0, 1024)

|str_cut| works by *directly* reseting the len value of the string.

And I have created a first-draft PR at https://github.com/php/php-src/pull/3483 , I am also going to create an RFC.

I am looking forward to your thoughts.


Zhang Junzhi
Sorry, only registered users may post in this forum.

Click here to login