I am reading a json file like this:
$path = storage_path() . "/userexam.json";
$json = json_decode(file_get_contents($path), true);
foreach($json as $js){
dd($js);
}
And the result of dd($js) which shows every single element of json goes like this:
array:13 [▼
"_id" => "d4466d06-3d47-41c4-aa5e-664752d84004"
"user" => "0123456789"
"exam" => "First Exam"
"total_time_in_minute" => 8640
"number_of_question" => 17
"start_time" => array:1 [▶]
"questions" => array:17 [▶]
"last_question" => 10
"is_finished" => false
"result" => null
"updated_at" => array:1 [▶]
"created_at" => array:1 [▶]
"score" => null
]
Now I want to push these elements into a single array.
So I did this:
$array_results = [];
foreach($json as $js){
array_push($array_results, $js);
}
dd($array_results);
But now the results of dd($array_results) goes like this:
As you can see it does not show the sub-arrays start_time, questions, updated_at and created_at and only a count number exists.
So how can I push the whole arrays into a new one while they're sub-arrays also exist in the new array?
