Special Characters

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
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

Special Characters

Post by quadoc »

Is there a way that PHP can intercepts keyboard inputs. I'm try to produce special characters when a user type a combination of keys. For example, if the user type a' , have the output display á, or if the user type e^ , have the output display ê . Does anyone have any tips? Thanks... :?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

If you're wanting to do this on the page before it's submitted, you'd have to use a client side language, as PHP wouldn't handle it.

If you're wanting to change the input into a different character set, I found the functions iconv() and recode_str().

If you're just wanting to change a set of certain characters, like your example, str_replace would be suitable.

Code: Select all

$data = $_POST['data'];

$combinations = array("e^","a'","etc");
$replacements = array("specialchar1","specialchar2","etc");

// sorry, I don't know how to do the special characters 

$newdata = str_replace($combinations,$replacements,$data);
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

Post by quadoc »

Thanks for the tips. But I've found out that there is a onkeyup even handler that you can use with the form.
Post Reply