Home >Backend Development >PHP Tutorial >PHP5.4开始数组成员访问支持函数返回值访问

PHP5.4开始数组成员访问支持函数返回值访问

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-20 13:04:56965browse

PHP数组成员访问解析(Array dereferencing*)

处理数组再也不需要临时变量了。

假设我们需要获取Fang Bin Xin的middle name,

PHP5.4开始数组成员访问支持函数返回值访问

echo explode(‘ ‘, ‘Fang Bin Xin’)[1]; // Bin

PHP 5.4之前,我们需要这样:

$tmp = explode(‘ ‘, ‘Fang Bin Xin’);

echo $tmp[1]; // Bin

现在,我们可以这样玩了


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn