在PHP字符串中交换批量字符

Hopefully this is not a difficult one for you guys, I am having an issue with character swapping for a full set of characters.

This is What I have so far;

// String to Convert
$rawstring = $_REQUEST['message'];

// Arrays
$original =     array('a', 'b', 'b', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',);
$replacements = array('z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a', '9', '8', '7', '6', '5', '4', '3', '2', '1', '0',);
//Final string
$Response = str_replace($original, $replacements, $rawstring);

For fairly obvious reasons, this is not giving a desired result as by the time the parser gets into the second half of the array it is converting characters it has already converted.

I have seen in some other questions the use of shifting characters, which in the above example would work because its currently straight forward, however I am looking to be able to change the 'encoder' (if you will) to adjust to different letter combinations.

I once again (as always) appreciate your help and look forward to getting this done :)

P.S. I understand this only takes into account lower case at this point in time.

To translate characters one by one, use strtr instead:

$Response = strtr($rawstring, array_combine($original, $replacements));