我对这个数组有点兴奋,所以我感谢任何解决方案,评论,任何事情。我有这样的数组:
array(3) {
[0]=>array(1) {
["ToursPrices"]=>array(1) {
["forced"]=>string(1) "1"
}
}
[1]=>array(1) {
["ToursPrices"]=>array(1) {
["forced"]=>string(1) "0"
}
}
[2]=>array(1) {
["ToursPrices"]=>array(1) {
["forced"]=>string(1) "0"
}
}
}
我想检查forced
元素以查看所有forced
元素是否具有值" 1"。如果所有这些都有价值" 1"我需要设置$all_forced = true
,否则我需要设置$all_forced = false
。任何想法我该怎么做?在此先感谢您的答案。
答案 0 :(得分:0)
$all_forced = true;
$d = array(
array('ToursPrices'=> array('forced'=>1)),
array('ToursPrices'=> array('forced'=>1)),
array('ToursPrices'=> array('forced'=>0)),
);
foreach($d as $el){
if(!$el['ToursPrices']['forced']){
$all_forced = false;
break;
}
}
debug($all_forced);