Question

I have a multi dimensional array in PHP.

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

When I want to use it, 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?

Was it helpful?

Solution

You can use extract() to do exactly that.

OTHER TIPS

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']

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top