Cara Transpose Array PHP
$arr = [
'name' => ['a', 'b', 'c'],
'age' => [ 2 , 1 , 3 ]
];
$result = [];
$keys = array_keys($arr);
for ($row = 0, $rows = count(reset($arr)); $row < $rows; $row++) {
foreach ($keys as $key) {
$result[$row][$key] = $arr[$key][$row];
}
}
echo '<pre>' . print_r($result, true) . '</pre>';
Lanjut Part : 1
Jam : 16:04:58
Durasi Part : 0:0:1
Durasi Total : 0:0:1
Punya Pertanyaan , Silahkan Whatsapp Langsung
Muhammad Ullil Fahri
WA : 089696380422
Tautan WA : https://wa.me/message/SG4YA2XQP5FPE1
Muhammad Ullil Fahri
WA : 089696380422
Tautan WA : https://wa.me/message/SG4YA2XQP5FPE1