php - Check same element in every subarray -
i stuck bit array appreciate solution, comment, anything. have array this:
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" } } }
i check forced
element see if forced
elements have value "1". if of them have value "1" need set $all_forced = true
, else need set $all_forced = false
. ideas how can that? in advance answers.
$all_forced = true; $d = array( array('toursprices'=> array('forced'=>1)), array('toursprices'=> array('forced'=>1)), array('toursprices'=> array('forced'=>0)), ); foreach($d $el){ if(!$el['toursprices']['forced']){ $all_forced = false; break; } } debug($all_forced);
php cakephp
No comments:
Post a Comment