Free Programming Tutorials & Source Code

 
  • Increase font size
  • Default font size
  • Decrease font size
Home PHP Remove characters from a string except numbers and letters

Remove characters from a string except numbers and letters

E-mail
(1 vote, average: 5.00 out of 5)
If you want to remove all characters and special symbols from a string in php, use the following code snippet:


 
<?php

$string = "remove *unwanted !character% from my string 1212&&";
$clean_string= ereg_replace("[^A-Za-z0-9]", "", $string);
echo $clean_string

?>