9){ $p_d = substr($d, 0, 1); $a_d = substr($d, 1, 1); } else{ $p_d = 0; $a_d = intval(substr($d, 1, 1)); } $d_sum = $p_d + $a_d; // echo '$d : ' . $d . " "; // echo '$d_sum : ' . $d_sum . "\n"; if($d_sum === $m){ $happyday += 1; } } } echo $happyday;