[英]check if array exists in php mongodb?
如何檢查數組是否存在於php中。
我在mongodb集合的某些行中使用了名為$ contact [“ categories”]的數組。 有些行沒有該數組。 如何檢查集合中是否存在特定數組?
使用$ exists參數檢查元素是否存在。
array('array_name' => array('$exists' => true))
您可以像這樣檢查索引的存在:
if (isset($contact["categories"])) {
}
要么
if( array_key_exists('categories', $contact) ) {
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.