php8.5
Home/ Manual/ bson / document/ MongoDB\BSON\Document::fromPHP

MongoDB\BSON\Document::fromPHP

PHP function Edit on GitHub ✎

(mongodb >=1.16.0)

Construct a new document instance from PHP data

Description

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::fromBSON
  • MongoDB\BSON\Document::fromJSON
  • BSON Types

Source: reference/mongodb/bson/document/fromphp.xml · from the official PHP manual (php/doc-en)