Hello i am fetching data from database by using mysqli_fetch_assoc() and getting this result
Array
(
[poi_id] => 1
[created_id] => 1
[tour_id] => 1
[poi_title] => Kankariya Lake
[poi_description] => Kankariya lake is a kankariya lake.
[poi_category] => Historical
[poi_base_price] => 10
[poi_type] => driving
[poi_address] => Kankaariya lake near maninagar
[poi_city] => Ahmedabad
[poi_state] => Gujaray
[poi_country] => India
[poi_latitude] => 23.006353
[poi_longitude] => 72.601181
[created_by] => Admin
[status] => 1
[time] => 2019-03-06 15:14:25
[distance] => 7.981589182296636
)
Array
(
[poi_id] => 2
[created_id] => 1
[tour_id] => 2
[poi_title] => Kankariya Lake
[poi_description] => Kankariya lake is a kankariya lake.
[poi_category] => Historical
[poi_base_price] => 10
[poi_type] => driving
[poi_address] => Kankaariya lake near maninagar
[poi_city] => Ahmedabad
[poi_state] => Gujaray
[poi_country] => India
[poi_latitude] => 23.006353
[poi_longitude] => 72.601181
[created_by] => Admin
[status] => 1
[time] => 2019-03-07 16:51:11
[distance] => 7.981589182296636
)
Array
(
[poi_id] => 3
[created_id] => 1
[tour_id] => 2
[poi_title] => Kankariya Lake
[poi_description] => Kankariya lake is a kankariya lake.
[poi_category] => Historical
[poi_base_price] => 10
[poi_type] => driving
[poi_address] => Kankaariya lake near maninagar
[poi_city] => Ahmedabad
[poi_state] => Gujaray
[poi_country] => India
[poi_latitude] => 23.006353
[poi_longitude] => 72.601181
[created_by] => Admin
[status] => 1
[time] => 2019-03-07 17:06:44
[distance] => 7.981589182296636
)
So now i want to access perticular array element in for loop so how i can access that elements i want to compare latitude and longitude with all other lat long of array my updated code
while ($poi_array = mysqli_fetch_assoc($qry_res))
{
$poi_id=$poi_array['poi_id'];
$new[]=$poi_array;
//print_r($new);
$lat1=$poi_array['poi_latitude'];
$lon1=$poi_array['poi_longitude'];
//echo $new['poi_longitude'][1];
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km= $miles * 1.609344;
$meter=$km*1000;
//echo round($meter);
if($meter>1000)
{
$response2['success'] = true;
$response2['message'] = "Pointof Interest list successfully fetched";
}
$fetch_media="SELECT * FROM poito_poi_media WHERE poi_id='".$poi_id."'";
$media_qry_res = mysqli_query($con,$fetch_media);
if (mysqli_num_rows($media_qry_res) > 0)
{
while ($media_array = mysqli_fetch_assoc($media_qry_res))
{
$response4['media_id'] = $media_array['media_id'];
$response4['image'] = $media_array['poi_image'];
$response4['video'] = $media_array['poi_video'];
$response4['ar'] = $media_array['poi_ar'];
$response5[]=$response4;
$response6['media_array']=$response5;
}
}
else
{
$response6['media_array']=null;
}
$response['poi_id'] = $poi_array['poi_id'];
$response['poi_title'] = $poi_array['poi_title'];
$response['poi_description'] = $poi_array['poi_description'];
$response['poi_category'] = $poi_array['poi_category'];
$response['poi_base_price'] = $poi_array['poi_base_price'];
$response['poi_type'] = $poi_array['poi_type'];
$response['poi_address'] = $poi_array['poi_address'];
$response['poi_city'] = $poi_array['poi_city'];
$response['poi_state'] = $poi_array['poi_state'];
$response['poi_country'] = $poi_array['poi_country'];
$response['poi_latitude'] = $poi_array['poi_latitude'];
$response['poi_longitude'] = $poi_array['poi_longitude'];
unset($response5);
$response['media_array'] = $response6['media_array'];
$response3[]=$response;
$response2['data']=$response3;
}
if Distance of other element of array within 1000meter then only give response of just one element no need to add another data in array
means this are placeinfo too remove same place if one place come multiple time then we have to show only one place