How do you get the string value of a MongoID using PHP?
Believe this is what you're after.
$widget['_id']->{'$id'};
Something like this.
$widget = array('text' => 'Some text');$this->mongo->db->insert($widget);$widget['widgetId'] = $widget['_id']->{'$id'};echo json_encode($widget);
correct way is use ObjectId from MongoDB:
function getMongodbIDString($objectId){ $objectId = new \MongoDB\BSON\ObjectId($objectId); return $objectId->jsonSerialize()['$oid'];}
and do not cast the objectId like (string) $row['_id']
or $row->_id->{'$oid'}