Making simple converter with php

I want to make a php script that would read what a person submitted in a form and change stuff to what I set, such as a converter/encrypter/etc.


The Form -
Text to Convert:

I fill it in as -
Text to Convert: convert this

After being submitted, the php script would change "convert" to "FFconvert" and "this" to "FFthis" .

Basically, I want it like this for example:

$u65 = "A";
$c65 = "chr(65);";

If it finds $u65 (aka the letter A) in the formdata, it would change it to $c65 (aka chr(65);)and output that.

It's basically like a converter except I set what to convert to what.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

see php manual for

string strtr ( string str, string from, string to )

This function returns a copy of str, translating all occurrences of each character in from to the corresponding character in to and returning the result.
HiTechFail, it's not clear from your two differing examples what your goal is.  Please explain further.
HiTechFailAuthor Commented:
Michael, would that work for multiple characters?

And let me make an example code (TOTALLY MADE UP - NOT REAL PHP):

They fill in the form on my site, after that, I want a php script to change each letter they typed (Normal text) to something I choose.

$t1 = "A"; THIS WOULD BE CHANGED TO $b1 = "gA";
$t2 = "B"; THIS WOULD BE CHANGED TO $b2 = "kB";
$t3 = "C"; (and so on, whole alphabet)

Therefore, if I submitted "ab", it would convert it to "gAkB"
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

are you always adding just one character to every character they type?
HiTechFailAuthor Commented:
Nono, only an example.

What I'm trying to do is convert text to it's chr(); equivalent.

Such as, the capital letter A would be chr(65);

Trying to make a converter to convert regular text into chr()'s
something as simple as this?
for ($i=0; $i<strlen($input); $i++ )
  $output.='chr('.(int) ord($input[$i])."');";
echo $output;

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HiTechFailAuthor Commented:
Yes that looks like it would work, and I would be able to make $input collect what was submitted in the POST form?
HiTechFailAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.