Write a PHP script to remove all characters from a string except a-z A-Z 0-9 or " ".
Sample string: abcde$ddfd @abcd )der]
<?php $string = 'abcde$ddfd @abcd )der]'; echo 'Old string : '.$string.''; $newstr = preg_replace("/[^A-Za-z0-9 ]/", '', $string); echo 'New string : '.$newstr."\n"; ?>
Sample Output:
Old string : abcde$ddfd @abcd )der] New string : abcdeddfd abcd der
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer