If substr() really was so bad, then surely we'd see userland
implementations of str_slice() in every project?

Jevon

On Wed, Mar 30, 2011 at 7:06 PM, Dan Birken <bir...@gmail.com> wrote:
> My apologizes if I am bringing up a topic that has been discussed before,
> this is my first time wading into the PHP developers lists and I couldn't
> find anything particularly relevant with the search.
>
> Here is a bug I submitted over the weekend (
> http://bugs.php.net/bug.php?id=54387) with an attached patch that adds a
> str_slice() function into PHP.  This function is just a very simple string
> slicing function, with the logical interface of str_slice(string, start,
> [end]).  It is of course meant to replace substr() as an interface for
> string slicing.
>
> I detailed the reasons I submitted the patch in the bug a little bit, but
> the main reason is that I think the substr() function is really overly
> confusing and just not an intuitive method of string slicing, which is
> exceedingly common functionality.  I realize we don't want to go around
> adding lots of random little functions into the language that don't offer
> much, but the problem with that is that if we have a function like substr()
> with an unusual and unintuitive interface, it becomes unchangeable due to
> legacy issues and then you can never improve.  I think this particular
> functionality is important enough to offer an updated interface.  In the bug
> I also pointed to two related bugs that would be essentially fixed with this
> patch.
>
> -Dan
>

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

Reply via email to