Construct a new document instance from PHP data

- « MongoDB\BSON\Document::fromJSON

- MongoDB\BSON\Document::get »

- PHP Manual
- MongoDB\BSON\Document
- Construct a new document instance from PHP data

# MongoDB\BSON\Document::fromPHP

(mongodb >=1.16.0)

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

### Description

final static public 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.

### Errors/Exceptions

- Throws MongoDB\Driver\Exception\InvalidArgumentException on argument parsing errors.

### See Also

- MongoDB\BSON\Document::fromBSON() - Construct a new document instance from a BSON string
- MongoDB\BSON\Document::fromJSON() - Construct a new document instance from a JSON string
- MongoDB\BSON\fromPHP() - Returns the BSON representation of a PHP value
- » BSON Types