php - Searching specific value in array -


i have array, , want find values correct => true:

   $quiz_array = array (             'question1' => array (                         'q1a1' => array (                                   'correct' => false,                                   'answer' => 'false answer1'                         ),                         'q1a2' => array (                                   'correct' => false,                                   'answer' => 'false answer2'                         ),                         'q1a3' => array (                                   'correct' => false,                                   'answer' => 'false answer3'                         ),                                           'q1a4' => array (                                   'correct' => true,                                   'answer' => 'correct answer'                         )             )     ); 

i want search, return q1a4 in case, because correct => true. trid using in_array , array_search no luck. suggestions?

here answer,

foreach($quiz_array $key=> $value) {   foreach($quiz_array[$key] $key=> $value) {     if( $value["correct"] ) {         echo $key ."<br>";       }   } } 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -