-2
json文字列を配列にデコードするのに問題がありますが、次のエラーが発生しています。json文字列を配列にデコードする
ERROR: (Parsing error occurred while we processed your request.)
$value = '"latitude":"1.3704","longitude":"103.8471","city":"singapore"';
$jsondata = file_get_contents($value);
$db = json_decode($jsondata,true);
for($i = 0; $i < sizeof($db); $i++){
$data = $db[$i];
if($data['city'] == $_POST['city']){
if(isset($_POST['radius'])){
$distance = 6371000 * acos(cos(deg2rad($data['latitude'])) * cos(deg2rad($latitude)) * cos(deg2rad($longitude) - deg2rad($data['longitude'])) + sin(deg2rad($data['latitude'])) * sin(deg2rad($latitude)));
if($distance <= $radius){
$inradius = true;
}
else{
$inradius = false;
}
}
else{
$inradius = true;
}
if($data['price'] >= $minPrice && $data['price'] <= $maxPrice && $data['area'] >= $minArea && $data['area'] <= $maxArea && $inradius === true){
if(empty($_POST['slika'])){
$result[] = $data;
}
else{
if(!empty($data['images'])){
$result[] = $data;
}
}
}