On 30 March 2011 15:05, Hannes Landeholm <landeh...@gmail.com> wrote:
> Parsing is a problem in many real-world
> problems and substr currently works great for that purpose.

That's funny because the first thing I thought when I read the
original mail was "oh that would be great for parsing." In fact, I've
just grep'ed through some code from a rich text parser I've been
working on and at first glance there are at ~5 occurences of substr()
that I would replace with str_slice(). There are also 15+ occurences
of substr() that would remain untouched. It's not black-and-white,
sometimes you want N characters starting from pos X, and other times
you want to cut the text from pos X and pos Y, and that's where
str_slice() would be welcome.

This thread shouldn't be a criticism of substr(), it would be
pointless. Its signature and behaviour will never change, unless
perhaps around April 1st as a practical joke on the millions of
websites it would break. The question is: is str_slice() useful, does
it fill a need and should it be included into PHP?

-JD

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to