Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<MongoDB\BSON\Document::fromJSONMongoDB\BSON\Document::get>
^MongoDB\BSON\DocumentLast updated: Mon, 26 Oct 2026

MongoDB\BSON\Document::fromPHP

(mongodb >=1.16.0)

MongoDB\BSON\Document::fromPHP — Construct a new document instance from PHP data

Description

final static public function MongoDB\BSON\Document::fromPHP(object|array $value): MongoDB\BSON\Document

Parameters

value (object|array)

A PHP object or array containing the document. When passing an array with numeric keys, the numeric values are converted to strings and used as document keys.

Return Values

Returns a new MongoDB\BSON\Document instance.

Errors/Exceptions

See Also


<MongoDB\BSON\Document::fromJSONMongoDB\BSON\Document::get>
^MongoDB\BSON\DocumentLast updated: Mon, 26 Oct 2026