AndrewP Posted November 11, 2010 Share Posted November 11, 2010 Hi, I'm pretty new to PHP, and I'm trying to write my own encoding/decoding script (not with base_64). I'd like to replace like all A's with B's, all B's with C's, C's with D's, and so on. How would I do this? Here's an example: String #1: "ABCDEFG" string #1 goes through my encryption string #2 (output): "BCDEFGH". How would I go about doing this? Thanks. Quote Link to comment Share on other sites More sharing options...
simshaun Posted November 11, 2010 Share Posted November 11, 2010 Here ya go, but I must say this is probably rather pointless. $string = 'ABCDEFGZ'; $strlen = strlen($string); for ($x = 0; $x < $strlen; $x++) { $string[$x] = chr(ord($string[$x]) + (strtoupper($string[$x]) == 'Z' ? -25 : 1)); } echo $string; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.