Newb Here, I need some help (input/output)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bow-viper1
Forum Newbie
Posts: 2
Joined: Fri Aug 01, 2003 2:02 pm

Newb Here, I need some help (input/output)

Post by bow-viper1 »

Alright, first post here. Great forums btw. If i'm posting this in the wrong place im sorry. I'm sort of just getting into html and I had a question on how to do something. Ok here it is.

I Want two text boxes, one above, one below. And a command button. When the button is pushed I want the Letters in the top textbox (Its Alpha only) to be kind of coded in the bottom textbox, I want it one to the right of each letter you push on the keyboard. Please not this is letters only, for example. A = S, S = D, P = [, And so on, and I understand there is no "Next letter to the right" command heh, It will probably have to be done letter by letter, thank god there is only 26

So just give me an example with 2 or 3 letters and I'll do the rest, I hope this wasn't too confusing.



I found a better way of putting it if you dont understand what I'm asking.

If I put this in the top textbox: "asdf"
Push button
I want it to say this in the bottom textbox: "sdfg"
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Take a look at the php string functions (see php.net for manual - can get a downloadable version if you don't have one already).

As an example, you could use str_replace() with a search array containing values for each letter in the alphabet, and a replace array the same but starting at B.

There are other ways to do it: using an alphabet string, string positions and integer arguments could create a less "hard-coded" solution so that you could vary your encryption substitutions easily.
jmarcv
Forum Contributor
Posts: 131
Joined: Tue Jul 29, 2003 7:17 pm
Location: Colorado

Post by jmarcv »

Code: Select all

$kbd=' asdf';
$char='d';
$newchar=substr($kbd,strpos($kbd,$char)-1,1);
echo $newchar;
output should be 's'
Post Reply