Есть php код который нужно вернуть в json формате, как это сделать?
echo('city: '.$city['city']['name_en'].'<br>');
echo('city code: '.$city['city']['id'].'<br>');
echo('city lat: '.$city['city']['lat'].'<br>');
echo('city lon: '.$city['city']['lon'].'<br>');
echo('country: '.$city['country']['name_en'].'<br>');
echo('country iso: '.$city['country']['iso'].'<br>');
echo('country code: '.$city['country']['id'].'<br>');
Как сделать переносы?
$arr = array('IP' => $ip,
'city' => $city['city']['name_en'],
'city code' => $city['city']['id'],
'city lat' => $city['city']['lat'],
'city lon' => $city['city']['lon'],
'country' => $city['country']['name_en'],
'country iso' => $city['country']['iso'],
'country code' => $city['country']['id'],);
echo json_encode($arr);