How does php MongoDB turn ObjectId into string

the query data is printed to see that _ id is objectID,. If it is directly converted to json,_id, it will be empty. Can you change objectID to string, and then to json?

Feb.26,2021

Yes, add a (string) type directly before _ id
ex: $info ['objectID'] = (string) $info [' _ id'];

Menu