$str = ''; for ($i = 0; $i < strlen($input); ++$i) { if (!is_numeric($input[$i])) { $str .= $input[$i]; } } $input = $str; echo $input, " är nu ok";