why cant I: array_keys($arr)[0] ?
| From: | operator at superprivate dot com | Date: | Sun, 04 Nov 2001 07:54:54 +0000 |
| Subject: | why cant I: array_keys($arr)[0] ? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-73379@lists.php.net to get a copy of this message | ||
Why does PHP give a parse error if you do:
echo array_keys($arr)[0];
It makes you assign the result of the function to a var first like this:
$arr = array_keys($arr);
echo $arr[0];
I just want to grab the 1st element of the array. Why does it make you do
it in 2 lines instead of letting you index right on the array that results
from the function?
A