函数名称:MongoDB\BSON\Document::toPHP()
适用版本:MongoDB 1.0.0及以上
用法:该方法将MongoDB\BSON\Document对象转换为PHP数组。
示例:
<?php
// 创建一个MongoDB\BSON\Document对象
$document = new MongoDB\BSON\Document([
'name' => 'John',
'age' => 30,
'email' => 'john@example.com'
]);
// 将MongoDB\BSON\Document对象转换为PHP数组
$array = $document->toPHP();
// 打印转换后的数组
print_r($array);
?>
输出:
Array
(
[name] => John
[age] => 30
[email] => john@example.com
)
注意事项: