Reputation: 13462
I have an array that looks like:
$fields = array(
"f1" => array("test"),
"f2" => array("other" => "values")
);
I'd like to retrive this information in one array:
$first_dimension = array("f1","f2");
Is there a function in PHP that can extract a particular dimension of an array directly? Is there a syntax shortcut for this?
Upvotes: 0
Views: 458
Reputation: 625057
Use array_keys().
$fields = array(
'f1' => array('test'),
'f2' => array('other' => 'values'),
);
$keys = array_keys($fields);
Upvotes: 6