Mega Code Archive

 
Categories / Php / Strings
 

Single-character substitutions

<?php   $qwerty = 'qwertyuiopasdfghjklzxcvbnm' . 'QWERTYUIOPASDFGHJKLZXCVBNM';   $dvorak = 'abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';   $message = "Start the attack when the sun rises.";   $encoded = strtr($message, $qwerty, $dvorak);   $decoded = strtr($encoded, $dvorak, $qwerty); ?>