PHP5.4新特性之Array dereferencing support
程序员文章站
2024-01-10 22:30:22
...
一个盼望已久的特性,终于有了,转之~
Array dereferencing是个好东西, 有了Array dereferencing, 以前的这种写法就再也不必要了:
list($name,) = explode(",", "Laruence, male");
?>
取而代之的是:
$name = explode(",", "b, x")[0];
另外, Array derefencing也可以出现再赋值语句的左值中, 也就是理论上你可以这么写:
explode(",", "test1, test2")[3] = "phper";
Array dereferencing是个好东西, 有了Array dereferencing, 以前的这种写法就再也不必要了:
list($name,) = explode(",", "Laruence, male");
?>
取而代之的是:
$name = explode(",", "b, x")[0];
另外, Array derefencing也可以出现再赋值语句的左值中, 也就是理论上你可以这么写:
explode(",", "test1, test2")[3] = "phper";
上一篇: PMP考试答题九技巧