The conventional way of doing this would be
$row = mysql_fetch_array($query);
echo $row['column'];
but I would like to know if it is possible to do something like
echo mysql_fetch_array($query)['column'];
I tried doing this on my local installation, but I get this error:
Parse error: syntax error, unexpected '[', expecting ',' or ';' in C:\Program Files (x86)\EasyPHP\www\array.php on line 5
This is mainly to reduce the number of lines in my code, as I'm writing a function that places a lot of mysql results into variables, and I don't want to have code that looks like
$row = ...
$this->data[] = $row[];
$row = ...
$this->data[] = $row[];
...and so on
function()['arraykey']is called array dereferencing, and it is possible in the newly released PHP 5.4, but not in earlier versions.