Re: substr/array_slice in []
| From: | Alexey Zakhlestin | Date: | Tue, 09 Oct 2007 06:57:38 +0000 |
| Subject: | Re: substr/array_slice in [] | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-32709@lists.php.net to get a copy of this message | ||
On 10/9/07, Antony Dovgal <tony@daylessday.org> wrote:
> On 09.10.2007 06:32, Andrei Zmievski wrote:
> > I will use an example:
> >
> > $foo = substr($bar, 0, 5) . "-" . substr($bar, 5);
> >
> > or
> >
> > $foo = $bar[:5] . "-" . $bar[5:];
> >
> > I would argue that the second line is hardly more cryptic than the
> > first one.
>
> How come?
> It looks like you're reading $bar[':5'], but forgot the quotes.
> On the other side, what could be easier than a function call?
operator is definitely easier because it lets us reuse the same syntax
for strings and arrays (and people would need to learn one operator
instead of 2 functions and 2 different concatenation operators)
>
> > And if we were concerned that concerned about duplicate
> > functionality, we probably wouldn't have SimpleXML and similar things.
>
> Mistakes done in the past do not mean we should continue to do them in the future.
simplexml is a mistake? :-/
then DOM is, probably, a mistake too… (it can be implemented in
userland using SAX functions)
I always thought, that simplexml was the reason xml became "fun" in
php (and that was the reason which made a lot xml-programmers upgrade
to php5)
--
Alexey Zakhlestin
http://blog.milkfarmsoft.com/