0

大多数时候,当有一个名为 func1 的函数并返回一个数组时,我使用此方法来访问该返回数组的特定索引:

$myarray=func1();
echo $myarray['AssIndex'];

有没有办法在一行中访问它?像这样的东西?

// the brackets are not working. this is only to make my meaning clear.
echo {func1}['AssIndex'];
4

1 回答 1

3

从 PHP 5.4 开始,您可以这样做:

echo func1()['AssIndex'];

这称为函数数组解引用

于 2013-09-14T22:48:44.917 回答