Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
配列がphpに存在するかどうかを確認する方法。
mongodbコレクションのいくつかの行に$contact["categories"]という配列があります。一部の行にはその配列がありません。特定の配列がコレクションに存在するかどうかを確認する方法は??
$exists パラメータを使用して、要素が存在するかどうかを確認します。
array('array_name' => array('$exists' => true))
次のようにインデックスの存在を確認できます。
if (isset($contact["categories"])) { }
また
array_key_exists()
if( array_key_exists('categories', $contact) ) { }