在文档中,我想为我的收藏中的每个人存储唯一的电话号码,如下所示:
phones: {
"5551112222": {
extension: "101",
type: "Mobile"
},
"8005554444": {
extension: "225",
type: "Work"
},
},
name: {
first: "john",
last: "smith"
}
我的 PHP 代码可以访问它,这让我可以访问扩展名和类型,但是我如何访问数字部分,因为 $d 显然不起作用,因为它只返回整个数组?
foreach ($cursor['phones'] as $d) {
echo 'number: ' . $d . '<br />ext. ' . $d['extension'] . '<br />type: ' . $d['type'];