It's happening because it changes multiple times during the preg_replace.
try this:
PHP Code: 

<?php
$key 
$_SERVER['QUERY_STRING'];
// used for testing
// $key = 'abcdefghijklmnopqrstuvwxyz0123456789';
$characters = array('/a/','/b/','/c/','/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/');
$scrambles = array('0','1','2','3','4','5','6','7','8','9','a','s','d','f','g','h','j','k','l','q','w','e','r','t','y','u','i','o','p','z','x','c','v','b','n','m');
$result '';
$ctr =0;
$one 1;
while (
$ctr strlen($key)) {
    
$k substr($key,$ctr,1);
    
$out preg_replace($characters[$ctr], $scrambles[$ctr], $k$one);
  
$result .= $out;
$ctr++; }
echo 
"Original:<br/>";
echo 
$key."<br/>";
echo 
"Scrambled:<br/>";
echo 
$result;
?>