What is the best approach to restructure a multidimensional array in PHP, grouping 'label' and 'value' in separate arrays?

When restructuring a multidimensional array in PHP to separate 'label' and 'value' into separate arrays, the best approach is to iterate through the original array and extract the 'label' and 'value' elements into their respective arrays. This can be achieved by creating two new arrays to store the 'label' and 'value' data, and then populating these arrays accordingly.

// Original multidimensional array
$originalArray = [
    ['label' => 'Name', 'value' => 'John'],
    ['label' => 'Age', 'value' => 30],
    ['label' => 'City', 'value' => 'New York']
];

// Initialize empty arrays for 'label' and 'value'
$labels = [];
$values = [];

// Iterate through the original array and extract 'label' and 'value'
foreach ($originalArray as $item) {
    $labels[] = $item['label'];
    $values[] = $item['value'];
}

// Output the separated 'label' and 'value' arrays
print_r($labels);
print_r($values);