Current array structure
array:2 [
"name" => "john"
"data" => array:3 [
0 => array:2 [
"id" => 191109
"ref_num" => "INV9002"
]
1 => array:2 [
"id" => 191110
"ref_num" => ""
]
]
I'm trying to copy id to ref_num if ref_num is null. So far I did try like
Code
$izero = //that data structure above
foreach($izero['data'] as $key => $value) {
if($value['ref_num'] === null) {
$value['ref_num'] = $value['id'];
}
$izero['data'] = $value;
}
$echo $izero
The result in izero missed the second array. It only keep the first array. Example if my data got 50 arrays, now it become the only one with first array.
The expected result should be like
array:2 [
"name" => "john"
"data" => array:3 [
0 => array:2 [
"id" => 191109
"ref_num" => "INV9002"
]
1 => array:2 [
"id" => 191110
"ref_num" => "191110"
]
]