By John Koster
The divide
helper method will take the given $array
and create two new arrays. The first array will be all of the keys from the original $array
and the second array will be all of the values.
1<?php
2
3use Illuminate\Support\Arr;
4
5$myArray = [
6 'animal' => 'Araripe Manakin',
7 'plant' => 'Pineland Wild Petunia'
8];
9
10$myArray = Arr::divide($myArray);
The final result would be:
1array(2) {
2 [0] array(2) {
3 [0] "animal"
4 [1] "plant"
5 }
6 [1] array(2) {
7 [0] "Araripe Manakin"
8 [1] "Pineland Wild Petunia"
9 }
10}
#array_divide($array)
The array_divide
function is a shortcut to calling Arr::divide
. This function is declared in the global namespace.
∎