I have a array $document
after query findOne()
Array ( [timestamp] => 1624382717 [_id] => stdClass Object ( [$id] => 60d2f531a5476f4eb220402b ) )
I want get 60d2f531a5476f4eb220402b
by use $document['_id']->__toString();
but it never work
Advertisement
Answer
The stdClass object does not have any methods by default, so you address the $id
field like this
echo $document['_id']->{'$id'};