$value){ if ($array[$key] == $array[$key+1]) { $OK ++; } else { $NG ++; } } if ($OK == $count-1) { echo $array[0]; } else { echo "-1"; }