$bamboo[$i+2] && $bamboo[$i] != $bamboo[$i+2]){ $ans ++; } } echo $ans;