Hey everyone,

I wrote a Caesar cipher (a script where, given a message, the letters in the message are shifter x number of places; e.g. A => D, B => E, C => F, X => A, Y => B, Z => C, etc.). It works but it shifts all ASCII characters. I want to exclude characters that are not A-Z or a-z (outside the ASCII values of 65 - 90 and/or 97 - 122) so that spaces, punctuation, numbers all remain the same instead of shifting as well.

The script is here:

PHP Code:
for ($i=0$i strlen($string); $i++) {
$ascii ord($string[$i]);
    for (
$j=0$j $sp$j++) {
        if (
$ascii == 90) { //uppercase bound
$ascii 65//reset back to 'A' 

        else if (
$ascii == 122) { //lowercase bound
$ascii 97//reset back to 'a' 

        else {
$newstring[$i] = chr($ascii);
$encstring $newstring;
Any help would be appreciated as I can't figure it out. If you want to see it in action it's here.