I have a problem where I want to put a random array with random count of how many it is inside an array. I want to do it like the following.
// Array don't have exact count of how many data is there
$array = array(1,2,3,4,.....)
$data['data'][] = array(
$id,
$date_file,
$emp_id,
$name,
$from_to,
$reason,
$status,
);
I want to put the $array inside of $data. But it's not supposed to be a nested the array I want it to be on the same field as id, date_file, emp_id, etc.
The output I want is like this
array:1 [▼
0 => {#401 ▼
+"id": 1
+"date_file": "2019-07-03 00:00:00"
+"emp_id": 1
+"name": aysan
+"from_to": "2019-07-03 00:00:00"
+"1": 1 //where I want to put the other array start here
+"2": 2 //The number of array is random or different from the others I want to put
+"reason": none
+"Status": "For Approval"
}
]
The $array need to be foreach but I don't think I can do that inside of array
array_merge. "Merges the elements of one or more arrays together... If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended."array_slice, something like this.