<?php
$result = json_decode('[
{
"birth_place": "Administrasi Jakarta Barat",
"jumlah_data_user": "3",
"id": "716,764,922",
"name": "Elvina Nuraini,Rina Kezia Novitasari,Viktor Firmansyah M.Pd",
"birth_date": "1975-08-28,1988-06-07,1989-05-13",
"gender": "female,female,male"
},
{
"birth_place": "Administrasi Jakarta Pusat",
"jumlah_data_user": "2",
"id": "993,866",
"name": "Mursinin Banawa Marbun M.Pd,Ibrahim Gunawan",
"birth_date": "1991-12-27,1995-01-01",
"gender": "male,male"
}
]', true);
var_export(
array_map(
fn($row) => [
'birth_place' => $row['birth_place'],
'jumlah_data_user' => $row['jumlah_data_user'],
'users' => array_map(
fn(...$cols) => array_combine(['id', 'name', 'birth_date', 'gender'], $cols),
explode(',', $row['id']),
explode(',', $row['name']),
explode(',', $row['birth_date']),
explode(',', $row['gender'])
)
],
$result
)
);
- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- array (
0 =>
array (
'birth_place' => 'Administrasi Jakarta Barat',
'jumlah_data_user' => '3',
'users' =>
array (
0 =>
array (
'id' => '716',
'name' => 'Elvina Nuraini',
'birth_date' => '1975-08-28',
'gender' => 'female',
),
1 =>
array (
'id' => '764',
'name' => 'Rina Kezia Novitasari',
'birth_date' => '1988-06-07',
'gender' => 'female',
),
2 =>
array (
'id' => '922',
'name' => 'Viktor Firmansyah M.Pd',
'birth_date' => '1989-05-13',
'gender' => 'male',
),
),
),
1 =>
array (
'birth_place' => 'Administrasi Jakarta Pusat',
'jumlah_data_user' => '2',
'users' =>
array (
0 =>
array (
'id' => '993',
'name' => 'Mursinin Banawa Marbun M.Pd',
'birth_date' => '1991-12-27',
'gender' => 'male',
),
1 =>
array (
'id' => '866',
'name' => 'Ibrahim Gunawan',
'birth_date' => '1995-01-01',
'gender' => 'male',
),
),
),
)
preferences:
115.82 ms | 404 KiB | 91 Q