$start = Array(25000, 30000, 40000, 15900, 46000); $end = Array(45000, 47000, 60000, 55000, 85000); $cnt2 = 0; foreach($start as $val) { $cnt = 0; for($i=0;$i<count($start); $i++) { if($start[$i] <= $val && $val < $end[$i]) $cnt++; if($cnt == count($start)) $start_budget = $val; elseif($cnt >$cnt2) { $cnt2 = $cnt; $start_budget = $val; } } if($cnt2 == 0) $cnt2 = $cnt; } $cnt2 = 0; foreach($end as $val) { $cnt = 0; for($i=0;$i<count($end); $i++) { if($start[$i] < $val && $val <= $end[$i]) $cnt++; if($cnt == count($end)) $end_budget = $val; elseif($cnt > $cnt2) { $cnt2 = $cnt; $end_budget = $val; } if($cnt2 == 0) $cnt2 = $cnt; } } echo $start_budget; echo "<br/>"; echo $end_budget;
You must be logged in to post a comment.