using result of function in same line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ok here's the problem - in some languages (like javascript or c# for
instance) you could use the results of a function in same line as your call.
say you have a function foo that returns an array, you can do something like

print foo()[4];

this will print the 5th element of whatever array foo returned.
but in php, it seems like you have to break it up into 2 calls like this:

$x = foo();
echo $x[4];

i find it hard to believe that you can't do

echo foo()[4];

so... how can u go about this?

thanks,
igor

and also, what is that called when you can do it in same line?

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux