PHP arrays: retrieving one dimension
I have an array that looks like this:
$fields = array(
"f1" => array("test"),
"f2" => array("other" => "values")
);
I would like to get this information in one array:
$first_dimension = array("f1","f2");
Is there a function in PHP that can directly extract a specific dimension of an array? Is there a syntax shortcut for this?
0
a source to share
2 answers
Use array_keys () .
$fields = array(
'f1' => array('test'),
'f2' => array('other' => 'values'),
);
$keys = array_keys($fields);
+6
a source to share