Friday, 15 July 2011

Replace string letters with nth alphabet character in PHP -


How do I change letters in letters with their + N cospaintent?

For example, replace each character with its +4Cospendent, as shown below:

  abcdefghijklmnopqrstu vwxyz รข ???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? a???? Efghijklmnopqrstuvwxy zabcd   

Therefore, if I have the string johnny , then it should be nslrrc .

You can create a character-of-character substitution with:

  $ shiftBy = 4; $ Alphabet = 'abcdefghijklmnopqrstuvwxyz'; $ NewAlpha = substr ($ alphabet, $ shiftBy). Substr ($ alphabet, 0, shift shift); Echo Strat ("Johnny", $ alphabet, $ newAlpha); // nslrrc   

Of course, it considers all the lowercase examples of your example. Politics complicates things.

Bonus: also works with negative changes

No comments:

Post a Comment