PHP
12
Вклад в тег
function createTableFromJson(array $json){
$result = "";
if(isset($json["tables"])){
foreach($json["tables"] as $tableName => $data){
$result .= "CREATE TABLE `".$tableName."`";
if(isset($data["columns"]) && count($data["columns"]) >= 1){
$result .= " (";
$columnDefinations = [];
foreach($data["columns"] as $columnName => $columnDefination){
$columnDefinations[] = "`".$columnName."` ".$columnDefination."";
}
$result .= implode(", ", $columnDefinations);
if(isset($data["mods"])){
$result .= ", ".implode(", ", $data["mods"]);
}
$result .= ")";
}
$result .= ";".PHP_EOL;
}
}
return $result;
}
echo createTableFromJson(json_decode($твоя_строка_с_json));
$response = json_decode(file_get_contents("https://cugadese.000webhostapp.com/weather?city=penza"), true);
var_dump($response); //смотрим что у нас в ответе