Re: Amendment to String Problem
| From: | Jim | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: Amendment to String Problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-26973@lists.php.net to get a copy of this message | ||
If that is what you really want to do, I would do it like you would do a
sort routine, use an intermediary character similar to a third variable when
swapping variable contents:
$passroutine = str_replace("a", "þ", $passroutine);
$passroutine = str_replace("z", "a", $passroutine);
$passroutine = str_replace("þ", "z", $passroutine);
do this for the 13 pairs of characters.
Hope this helps
Jim
-------Original Message-------
From: Chris Payne
Date: Wednesday, April 09, 2003 8:03:52 PM
To: php
Subject: [PHP-DB] Amendment to String Problem
Hi there Everyone,
Here's a better example of the problem i'm having, there is probably a MUCH
better way to do this, but here goes.
I am using the following code:
$passroutine = 'abcdefghijklmnopqrstuvwxyz';
$passroutine = str_replace("a", "z", $passroutine);
$passroutine = str_replace("b", "y", $passroutine);
$passroutine = str_replace("c", "x", $passroutine);
$passroutine = str_replace("d", "w", $passroutine);
$passroutine = str_replace("e", "v", $passroutine);
$passroutine = str_replace("f", "u", $passroutine);
$passroutine = str_replace("g", "t", $passroutine);
$passroutine = str_replace("h", "s", $passroutine);
$passroutine = str_replace("i", "r", $passroutine);
$passroutine = str_replace("j", "q", $passroutine);
$passroutine = str_replace("k", "p", $passroutine);
$passroutine = str_replace("l", "o", $passroutine);
$passroutine = str_replace("m", "n", $passroutine);
$passroutine = str_replace("n", "m", $passroutine);
$passroutine = str_replace("o", "l", $passroutine);
$passroutine = str_replace("p", "k", $passroutine);
$passroutine = str_replace("q", "j", $passroutine);
$passroutine = str_replace("r", "i", $passroutine);
$passroutine = str_replace("s", "h", $passroutine);
$passroutine = str_replace("t", "g", $passroutine);
$passroutine = str_replace("u", "f", $passroutine);
$passroutine = str_replace("v", "e", $passroutine);
$passroutine = str_replace("w", "d", $passroutine);
$passroutine = str_replace("x", "c", $passroutine);
$passroutine = str_replace("y", "b", $passroutine);
$passroutine = str_replace("z", "a", $passroutine);
which is SUPPOSED to replace letters, a because z and so on, but after it
gets to m it screws up and displays:
abcdefghijklmmlkjihgfedcba
How can I do the above code in such a way that it won't produce this
problem?
Any help will be greatly appreciated :-)
Regards
Chris