I have read through several problems that's the same as mine but I still couldn't understand how to query MongoDB inside PHP as I am new to both platforms.
Here's my query in MongoDB
db.tweets.find({},{"coordinates.coordinates": 1});
My initial PHP code
$document = $collection->find({},{"coordinates.coordinates": 1});
foreach($document as $doc)
{
var_dump($doc);
}
My code returns an error
Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\gmaps_thesis\main.php on line 20
Try the following code:
$collection->find([],['coordinates.coordinates' => 1]);
PHP uses []
for object and array notation instead of JavaScript's {}