Do you search for how to replace/remove illegal character (@#$%^&* etc) in your text string?
On this post I will share you simple code to make it.
This code will only allowed numbers (0-9) and characters (a-z).
my code :
<?php
$string = 'by^#^we%%&bs.b_((logs+)&#@pot.()*)(~co!~@#_+m';
$string = preg_replace('/[^0-9 a-z]+/i', '', $string);
echo $string;
?>
And below is code for replace multiple space on your text string
<?php
$string = 'by webs. blog spot. com';
$string = str_replace(array(' '),array(''),$string);
echo $string;
?>
Hope it will useful for all,
If you have questions or suggestions, please write your comment below.
Good Luck :)
No comments:
Post a Comment