bakedproject.com Blog Not just another WordPress weblog

12Mar/100

Remove symbols and punctuations from a string

A very simple function to remove symbols and punctuations from a word.

function replace_symbols($word) {
 $symbols = "~!@#$%^&*()_+=:;?.,";
 
 for($i=0;$i<strlen($symbols);$i++) {
  $word = str_replace($symbols[$i],'', $word);
 }
 
 return $word;
} // end of replace_symbols

We can add more symbols to the symbols string.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.