Converting an array [fields => values] to one [fields, values]
If I have an array like this:
[
field1 => value1,
field2 => value2,
field3 => value3
];

and I want to convert it to an array like this:
[
[field1, field2, field3],
[value1, value2, value3]
];

now I just took the keys and values and put them in another array:
[
array_keys($array),
array_values($array)
];

Is there a more elegant way to do this?

How can I convert an array with key-value pairs to an array with separate sub-arrays for the keys and values in PHP?
Before considering "elegant", first consider output consistency.  If you always want to create an array with two first level elements, your approach is suitable.
However, if you want an empty output array when your input array is empty, you'll need a different approach where the result array is only deepened when necessary such as...
Code: (Demo)
$result = [];
foreach ($array as $k => $v) {
    $result[0][] = $k;
    $result[1][] = $v;
}
var_export($result);


If you always want a two-element result, a body-less loop can avoid making any function calls in a concise way. (Demo)
$result = [[], []];
foreach ($array as $result[0][] => $result[1][]);
var_export($result);


Functional programming with array_reduce() can become ugly/verbose for this task. (Demo)
var_export(
    array_reduce(
        array_keys($array),
        function ($result, $k) use ($array) {
            $result[0][] = $k;
            $result[1][] = $array[$k];
            return $result;
        },
        []
    )
);

And if you are considering array_walk(), that is just going to work like a foreach() anyhow because it doesn't deliver its result payload as a returned value.

If you consider functional programming to be elegant, bear in mind that double-transposing with array-map() calls will not work when there is one element or less in your input array. Proof
