I have an array that has keys and values. For example,
Array (
[name] => aalaap
[age] => 29
[location] => mumbai
)
I want to convert the keys from this to values, but I want the values ββto appear right after the keys. For example,
Array (
[0] => name
[1] => aalaap
[2] => age
[3] => 29
[4] => location
[5] => mumbai
)
I can easily write an iterative function that will do this ... for example, for example:
array_flatten($arr) {
foreach ($arr as $arrkey => $arrval) {
$arr_new[] = $arrkey;
$arr_new[] = $arrval;
}
return $arr_new;
}
... but I'm trying to find out if it can be done using the array_combine, array_keys, array_valuesand / or array_merge, preferably in one, so I do not need to use a custom function.
Whether there is a?
source
share