note 107624 deleted from language.types.array by tularis
| From: | tularis@php.net | Date: | Wed, 22 Feb 2012 21:05:48 +0000 |
| Subject: | note 107624 deleted from language.types.array by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-186297@lists.php.net to get a copy of this message | ||
Note Submitter: rahul at amram dot name
----
As mentioned in one of the notes below, it is not possible to do something like this:
<?php
$a = function_that_returns_an_array()['some_index'] ;
?>
However, using anonymous functions, it should be possible to access an element of an array that is
returned by a function in a single line. Here is the example.
<?php
$a = call_user_func(function($arr){return $arr['some_index'];},
function_that_returns_an_array());
?>