views:

127

answers:

3

Hello!

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?

+2  A: 

You can use extract() to do exactly that.

Peter Bailey
A: 

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);
Lance Rushing
A: 

$one = $f['one']

Eric