php - How can I loop through a two-dimensional array and display the values if another value is true? -


i have array like:

0 name => 'john', age => '99', istheone => boolean true  1 name => 'jeff', age => '88', istheone => boolean false 

what need is, each row in array, display contents if field istheone true.

i thought i'd need use while loop this, i'm bit stuck. don't know how move forward this?

this should work you:

<?php      $array = array(                 0 => array(                     "name" => 'john',                     "age" => '99',                     "istheone" => true                 ),                  1 => array(                     "name" => 'jeff',                     "age" => '88',                     "istheone" => false                 )             );      foreach($array $subarray) {         foreach($subarray $k => $v) {             if($k == "istheone" && $v == true)                 echo "key: " . $k . " value: " . $v;         }     }  ?> 

output:

key: istheone value: 1 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -