Re: RFC Karma Request

From: Date: Wed, 27 Jul 2016 11:53:50 +0000
Subject: Re: RFC Karma Request
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-94724@lists.php.net to get a copy of this message
2016-07-27 12:24 GMT+02:00 Christoph Becker <cmbecker69@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

« previous php.internals (#94724) next »