2016-07-27 12:24 GMT+02:00 Christoph Becker <cmbecke...@gmx.de>: > On 27.07.2016 at 02:55, Davey Shafik wrote: > > > Ah, I missed that. If we had ranges (e.g. $string[0..4] or > $string[-1..4]) > > that'd work, but we don't. > > However, that still would require something like > > $str[0..mb_strlen($needle)-1] == $needle >
I've been working on range operator some time ago and had problem with double-dot ".." as an operator because of conflict with concat operator. 0..5 could be 0. . 5, or 0 . .5 white spaces are problem here, unfortunately dot is concat operator and decimal separator. > > > Now I see some value in the function, though still perhaps not enough to > > justify above and beyond strpos etc. > > One advantage of the new functions over userland implementations would > be efficiency. A strpos() would still require to search the whole > string if the $needle is not found. substr() and string slices would > require a copy unless that would be optimized, if a general optimization > is possible at all. > > Not sure, if I like to see yet two more string functions in the global > namespace, though. > > -- > Christoph M. Becker > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- pozdrawiam -- Michał Brzuchalski