I know there is a function, I think its preg_replace(); that will remove all things other than letters, number, spaces (It may be ereg_replace()😉 could someone please write a code to show me how to do this.
Thanks
Jack
Yep, preg_replace(), like this:
<?PHP $text = "This is a test."; $newtext = preg_replace("/[^A-Za-z0-9 ]/", "", $text); echo $newtext; ?>
Does this do spaces too? and thank you.
Yes it will. The above will print "This is a test" (no period)
The space is included in the function:
$newtext = preg_replace("/[^A-Za-z0-9 ]/", "", $text); right here ^