I sometimes get values from an array like this: $var = array ('key1' => 'value1')['key1'];
, so $var
should be equal to value1
I run code like this in a server having PHP v5.4.16 , for example, explode ('-', $str)[0];
and it works fine.
Now if I transfer this code to another server which uses PHP v5.3.10 I get an error (syntax error): syntax error, unexpected '[' ...
Is this because of the version? (I don't think so because the difference between versions is so small..), or some setting in the server? Can anyone enlighten me?