Str enhancement, final run
| From: | André Langhorst | Date: | Tue, 10 Jul 2001 16:00:09 +0000 |
| Subject: | Str enhancement, final run | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-59566@lists.php.net to get a copy of this message | ||
As it were Andi's last words, is it the finial decison now just to implement $foo{x} to retrieve a single char?
I'm asking this again, because it will be irreversible because it is not compatible with substr($foo,x) == $foo{x}!!!
And as I still do not agree that substr($foo,4,6) should be better than
$foo{4,6} I now have another (taken and modified from Zeev or Andi) offer, which *is intuitive*:
What about the range proposals? $foo{4..6} where $foo{6..} would mean to the end, no negative numbers, nothing else but at least that would simplify string processing a bit (although I am still in favor for the substr() solution).
I think even Zeev would agree that this is intuitive ;)
So far we have:
$foo{x} get char at pos x
$foo{x..} get chars from pos x to the end
$foo{x..y} get chars from pos x to y
Now what if we do not know the position of the last character?
$foo{x..-5} get chars from pos x to the minus 5
I tried to interprete this differently but I failed, isn't this called intuitive?
As an alternative we even modify it to
$foo{x..|} and $foo{x..|-4}
if anyone feels better with it...
Comments welcome,
andré
ps. I do not remember the engine2 email address, if anyone could forward it...