Re: JavaScript conversion to PHP code...
| From: | Curt Zirzow | Date: | Mon, 26 Jul 2004 22:43:24 +0000 |
| Subject: | Re: JavaScript conversion to PHP code... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-191922@lists.php.net to get a copy of this message | ||
* 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!