Hello,
I want to return an array from function and reference an index all in
one line. Is this possible?
In the code below I want I want $yo to be the array(5,6).
Here is what I've tried,
function returnarray() {
return array('lose' => array(5,6), 'win' => array(9,8));
}
$yo = returnarray()['lose'];
var_dump($yo);
This yields a parse error.
function returnarray() {
return array('lose' => array(5,6), 'win' => array(9,8));
}
$yo = {returnarray()}['lose'];
var_dump($yo);
This yields a parse error.
function returnarray() {
return array('lose' => array(5,6), 'win' => array(9,8));
}
$yo = ${returnarray()}['lose'];
var_dump($yo);
This gives notices as the result of returnarray() is being converted to
a string. $yo === NULL...not what i want.
function returnarray() {
return array('lose' => array(5,6), 'win' => array(9,8));
}
$yo = returnarray()->['lose'];
var_dump($yo);
This yields a parse error.
function returnarray() {
return array('lose' => array(5,6), 'win' => array(9,8));
}
$yo = ${returnarray()}->['lose'];
var_dump($yo);
This yields a parse error.
Thanks for your help in advance.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php