$va = '{ "api": { "results": 16, "statistics": {
"Shots on Goal":
{ "home": "5", "away": "2" },
"Shots off Goal":
{ "home": "7", "away": "4" },
"Total Shots": { "home": "17", "away": "8" },
"Blocked Shots": { "home": "5", "away": "2" },
"Shots insidebox": { "home": "12", "away": "5" },
"Shots outsidebox": { "home": "5", "away": "3" }, "Fouls": { "home": "15", "away": "14" }, "Corner Kicks": { "home": "9", "away": "1" },
"Offsides": { "home": "2", "away": "2" }, "Ball Possession": { "home": "61%", "away": "39%" },
"Yellow Cards": { "home": "2", "away": "3" }, "Red Cards": { "home": "", "away": "" },
"Goalkeeper Saves": { "home": "1", "away": "4" }, "Total passes": { "home": "633", "away": "414" },
"Passes accurate": { "home": "575", "away": "365" }, "Passes %": { "home": "91%", "away": "88%" } } } } ';
$data = json_decode($va);
$sqlinsert = "INSERT INTO fixture_statistics (Shots_on_Goal_home,
Shots_on_Goal_away, Shots_of_Goal_home, Shots_of_Goal_away, Total_Shots_home, Total_Shots_away, Blocked_Shots_home, Blocked_Shots_away, Shots_insidebox_home, Shots_insidebox_away, Shots_outsidebox_home, Shots_outsidebox_away, Fouls_home, Fouls_away, Corner_Kicks_home, Corner_Kicks_away, Offsides_home, Offsides_away, Ball_Possession_home, Ball_Possession_away, Yellow_Cards_home, Yellow_Cards_away, Red_Cards_home, Red_Cards_away, Goalkeeper_Saves_home, Goalkeeper_Saves_away, Total_passes_away, Passes_percentage_away)";
$insert_value='';
foreach($data->api->statistics as $key=> $value){
if($key == 'Shots on Goal'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Total Shots'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Blocked Shots'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Shots insidebox'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Shots outsidebox'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Fouls'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Corner Kicks'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Offsides'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Ball Possession'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Yellow Cards'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Red Cards'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Goalkeeper Saves'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Total passes'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Passes accurate'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
elseif($key == 'Passes %'){
$insert_value.="'".$value->home."', '".$value->away."',";
}
}
$final_insert_query = rtrim($insert_value, ',');
$sqlinsert.='VALUES('.$final_insert_query.")";
echo $sqlinsert;
Он сгенерирует этот запрос для вашей таблицы.
INSERT INTO fixture_statistics (Shots_on_Goal_home,
Shots_on_Goal_away, Shots_of_Goal_home, Shots_of_Goal_away, Total_Shots_home, Total_Shots_away, Blocked_Shots_home, Blocked_Shots_away, Shots_insidebox_home, Shots_insidebox_away, Shots_outsidebox_home, Shots_outsidebox_away, Fouls_home, Fouls_away, Corner_Kicks_home, Corner_Kicks_away, Offsides_home, Offsides_away, Ball_Possession_home, Ball_Possession_away, Yellow_Cards_home, Yellow_Cards_away, Red_Cards_home, Red_Cards_away, Goalkeeper_Saves_home, Goalkeeper_Saves_away, Total_passes_away, Passes_percentage_away)VALUES('5', '2','17', '8','5', '2','12', '5','5', '3','15', '14','9', '1','2', '2','61%', '39%','2', '3','', '','1', '4','633', '414','575', '365','91%', '88%')