开发者

Separate multi dimensional array

开发者 https://www.devze.com 2022-12-09 13:23 出处:网络
I have a multi dimensional array in PHP. $f = array(\'one\' => array(*doesntmatter*), two => array());

I have a multi dimensional array in PHP.

$f = array('one' => array(*doesntmatter*), two => array());

When I want to use i开发者_StackOverflowt, I only want one of the arrays. (one or two or three etc) So I want to slice it into (in this case) two seperate arrays, like this:

$one = array(**); $two = array(**);

Can I solve this with a default function, or I have to write it by myself?


You can use extract() to do exactly that.


to explicitly call each member:

$foo = array('one' => array(1,2,3), 'two' => array(4,5,6));
$one = $foo['one'];
$two = $foo['two'];

or you can use extract()

extract($foo);
print_r($one);print_r($two);


$one = $f['one']

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号