selectCollection('kpmaster', 'kpu'); $cursor = $collection->find(['location' => ['$geoWithin' => ['$centerSphere' => [[76.93414657, 8.82302903], 500 / 3963.2]]]]); // foreach ($cursor as $document) { // echo $document["_id"] . "\n"; // } echo json_encode(iterator_to_array($cursor)); ?>