$value){ if ($bamboo[$key] < $bamboo[$key+1] && $bamboo[$key+1] > $bamboo[$key+2]){ $ans ++; } } echo $ans;