在PHP并行数组赋值 [英] Parallel array assignment in PHP
本文介绍了在PHP并行数组赋值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大多数语言可以很容易地采取像 [1,2,3]
,并指定这些值的变量 A $ C数组$ C>,
b
和 C
用一条命令。
例如,在Perl中,你可以做
Most languages make it easy to take an array like [1, 2, 3]
and assign those values to variables a
, b
, and c
with a single command.
For example, in Perl you can do
($a, $b, $c) = (1, 2, 3);
什么是在PHP相应的把戏?
What's the corresponding trick in PHP?
[感谢这么多的快如闪电的答案!我知道这是一个简单的问题,但都明显谷歌查询不转了答案,所以这是我尝试解决这个问题。]
[Thanks so much for the lightning fast answer! I know this is a trivial question but all the obvious google queries didn't turn up the answer so this is my attempt to fix that.]
推荐答案
使用 名单()
:
list($a, $b, $c) = $someArray;
这篇关于在PHP并行数组赋值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文