$string = trim(fgets(STDIN)); if($string_len = strlen($string)%2 === 0) { $length= $string_len = strlen($string)/2; $string_arr = str_split($string,$length); $i = 0; $base_string = $string_arr[0]; $compare_string = $string_arr[1]; if($base_string === $compare_string) { echo "YES"; } else { echo "NO"; } } else { echo "NO"; }