Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何删除mongodb子数组中的项?_Php_Mongodb - Fatal编程技术网

Php 如何删除mongodb子数组中的项?

Php 如何删除mongodb子数组中的项?,php,mongodb,Php,Mongodb,我的用户文档结构如下: { "_id" : ObjectId("5173b10fd0aa9af00d06395c"), "customer_id" : 1, "customer_fullname" : "Douglas E. Kelly", "customer_email" : "1@1.com", "customer_cityid" : "1", "customer_selections" : [15, 952, 17347, 343102, 20380, 51757, 235961, 119

我的用户文档结构如下:

{
"_id" : ObjectId("5173b10fd0aa9af00d06395c"),
"customer_id" : 1,
"customer_fullname" : "Douglas E. Kelly",
"customer_email" : "1@1.com",
"customer_cityid" : "1",
"customer_selections" : [15, 952, 17347, 343102, 20380, 51757, 235961, 119824, 134011,   168251, 297596, 175792, 196010, 210349, 226945, 250102, 274064, 328834, 354893, 472868,  555878]
}
因此,我想删除“客户选择”中的一个编号/项目。我们怎样才能做到这一点

更新: 我正在使用这个查询。但它并没有删除这个数字

  $response=$collection->update(array('customer_id' =>1), array('$pull' => array('customer_selections'=>$selectedcompanyid)));
var_dump($response)

通过使用$pull

 array(5) { ["updatedExisting"]=> bool(true) ["n"]=> int(1) ["connectionId"]=> int(3) ["err"]=> NULL ["ok"]=> float(1) }
db.yourColl.update( { id: ObjectId("5173b10fd0aa9af00d06395c") }, { $pull: { customer_selections: 952 } } )