Re: RFC - Array slice syntactic sugar

From: Date: Fri, 20 Mar 2015 13:17:32 +0000
Subject: Re: RFC - Array slice syntactic sugar
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-85286@lists.php.net to get a copy of this message
Alex Bowers wrote on 20/03/2015 13:09:
On 20 March 2015 at 13:04, Rowan Collins <rowan.collins@gmail.com <mailto:rowan.collins@gmail.com>> wrote:
    $version{4:} = '7!';
I'm sure this is a slight oversight on your end, but just to check. The change of using {} instead of [] is not because its a string, and is just a typo / example correct?
It's an alternative syntax, which I thought was only usable for string indexing [1] but is apparently legal on arrays as well [2]. I personally like the idea of string offsets having similar but slightly different syntax from array offsets, to make clear which you're using. I use {} instead of [] for that reason, but at the moment the syntaxes are completely interchangeable as far as I can tell. [1] http://php.net/manual/en/language.types.string.php#language.types.string.substr [2] http://php.net/manual/en/language.types.array.php#language.types.array.syntax.accessing Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#85286) next »