I work with databases in PHP and often fetch data from one. My question is: Can I write this in one line?
$res = mssql_fetch_assoc($result);
return $res['col'];
I have tried multiple approaches including
return (mssql_fetch_assoc($result))['col'];
and
return mssql_fetch_assoc($result)['col'];
but nothing seems to work.
Any ideas?
Only if you are on PHP >= 5.4.0, where this was implemented with the name array dereferencing.