Separate multi dimensional 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']
精彩评论