check associative array contains value

后端 未结 5 1714
粉色の甜心
粉色の甜心 2021-01-26 01:27
    Array (    
    [0] => Array ( 
               [questionID] => 47
               [surveyID] => 51
               [userID] => 31 
               [question         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-26 02:25

    As an alternative, my way independent of the array structure (assume $x holds your data structure):

    if (preg_match('/"required":[01]/',json_encode($x))) {
        // The array structure contains "required" => 0 or "required" => 1
    } else {
        // Negative
    }
    

提交回复
热议问题