可能的重复:
用于取消引用函数结果的 PHP 语法 https://stackoverflow.com/questions/742764/php-syntax-for-dereferencing-function-result
我有一个字符串,看起来像1234#5678。现在我这样称呼:
$last = explode("#", "1234#5678")[1]
它不起作用,有一些语法错误......但在哪里?我期望的是 5678$last
。这在 PHP 中不起作用吗?
Array dereferencing is not possible in the current PHP versions (unfortunately). But you can use list [docs] http://php.net/manual/en/function.list.php to directly assign the array elements to variables:
list($first, $last) = explode("#", "1234#5678");
UPDATE
自 PHP 5.4(2012 年 3 月 1 日发布)起,它支持数组解引用 http://php.net/ChangeLog-5.php#5.4.0.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)