Forum Moderators: coopster
$foo = some_function($bar)[1];
If I do it like this:
$zot = some_function($bar);
$foo = $zot[1];
The first construction would work in C or Python, but not in PHP. I seem to recall that there's an alternate syntax for directly referencing an array member of a function return, but for the life of me I can't find it on the PHP doc website. I believe I even used it years ago, but it's been a long time. Does anyone know how this is done?
Thought I had done that once too but if I had I certainly couldn't find it. Maybe it was in a different programming language and it just looked so familiar I thought I had done it in PHP ;-)
Anyway, you could always:
$foo = array_slice [php.net](some_function($bar),1,1);