php - check associative array contains value -
array ( [0] => array ( [questionid] => 47 [surveyid] => 51 [userid] => 31 [question_title] => choose one? [question_type] => dropdown [response] => 1.android 2.windows 3.blackberry [required] => 0 [add_time] => 0 ) [1] => array ( [questionid] => 48 [surveyid] => 51 [userid] => 31 [question_title] => it? [question_type] => bigbox [response] => yes no [required] => 1 [add_time] => 0 ) [2] => array ( [questionid] => 129 [surveyid] => 51 [userid] => 31 [question_title] => select [question_type] => single [response] => dfg hbk ghck hk [required] => 0 [add_time] => 0 ) )
this multidimensional
now want check array contains [required] => 1 or [required] => 0
i don't want traversing array
let's array name $myarray
so can -
foreach($myarray $arrelement) { if(isset($arrelement[required]) && $arrelement[required] == 1) //choose 1 or 0 in code per need { //traverse array , needful } }
Comments
Post a Comment