Re: Str enhancement, final run

From: Date: Tue, 10 Jul 2001 16:38:27 +0000
Subject: Re: Str enhancement, final run
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-59573@lists.php.net to get a copy of this message
At 06:00 PM 7/10/2001 +0200, André Langhorst wrote:
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
This option looks nice but I don't like the extensions mentioned below. I still think that people who need more complicated stuff can use substr(). But I know many don't agree with me so I prefer to wait a while with the discussion until we start advancing a bit in the Engine 2 implementation and then we will also have more of a technical basis to judge not only what is nice but also what is technically feasible. The only thing I think is pretty sure is that $foo{x} will work :) Andi
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...


« previous php.dev (#59573) next »