* Thus wrote Scott Fletcher:
> Hi, what is in your opinion is the best way to convert from JavaScript to
> PHP.... What I'm not entirely sure of is the
> "char_set.indexOf(input.charAt())"..... It look pretty tricky....
>
Sometimes a whole complete approach can be done:
> --snip--
> var algorithm = 8;
>
// shift the contents over and add the shifted to the end.
$trans = substr($char_set, $algorithm-1) .
substr($chars_set, 0, $algorithm);
$output = strtr($input, $trans_set, $trans);
If your $input string is of a significant length this will be more
efficient with the cost of some memory (strlen($trans_set)x2).
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php