$array = array(
'vegs' => 'tomatos',
'cheese' => false,
'nuts' => 765,
'' => null,
'fruits' => 'apples'
);
var_dump(in_array(false, $array, true)); //returns true because there is a false value
Wie streng zu prüfen, ob es mindestens ein nicht-false (string, true, int) Wert in Array nur oder irgendetwas mit in_array ist aber nicht foreach?in_array prüfen für nicht falsche Werte
var_dump(in_array(!false, $array, true)); //this checks only for boolean true values
var_dump(!in_array(false, $array, true)); //this returns true when all values are non-false
Warum beschränken Sie sich(), um in_array nur; Dies ist eine perfekte Verwendung für array_reduce() –
alles andere als nicht foreach – ihtus