Hello,
I am writing a program for a palindrome and would like to know if anyone knows of a script/function that eliminates various characters (whitespace, any non-digit, a non-blank character, a non-word character etc.).
Thanks for your help.
Sure. You're looking for regular expressions. Check out the preg_replace() function at PHP.net
If you have a specific regular expression that you can't figure out, let me know and I'll see if I can't help you cook one up.
cheers, Ben
Ben,
I think I will take you up on the offer.
For a palindrome php page I am creating I need to use preg_replace()to replace whitespace, tab keys, spaces between words.
Can you help me with that? I am just learning PHP.
Thanks!
Vincent
try this (haven't tested it, but it should be a start)
$var = preg_replace('/( |\t)+/','',$var);
Theoretically, this should toast all tabs and spaces in $var.