Health 2007 - Debt Consolidation - Boxing Class - Debt Consolidation - free machines directory

PDA

View Full Version : I want to remove non standard characters from form input


baris22
Apr 15th 2008, 12:05 pm
Hello,

What can i do to remove unwanted characters from form? I want to have numbers european letters and punctuation marks.

I just want to remove everything else.

Thanks

jayshah
Apr 16th 2008, 1:24 am
Here would be my method.

Create an array of acceptable characters (e.g. 'a','b',...,'0','1',...)

Preg_Split the input into single characters (see www.php.net/preg_split for sample code).

Foreach() every character, and if in_array($character, $validcharacters) add it to a new, final string (i.e. $valid_input .= $character).

I hope this helps,

Jay