Home >php教程 >php手册 >PHP5.4新特性之Array dereferencing support

PHP5.4新特性之Array dereferencing support

WBOY
WBOYOriginal
2016-06-13 10:46:591071browse

一个盼望已久的特性,终于有了,转之~
 
Array dereferencing是个好东西, 有了Array dereferencing, 以前的这种写法就再也不必要了:
 
    list($name,) = explode(",", "Laruence, male");
?>
取而代之的是:
 
$name = explode(",", "b, x")[0];
另外,  Array derefencing也可以出现再赋值语句的左值中, 也就是理论上你可以这么写:
 
explode(",", "test1, test2")[3] = "phper";

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