How to remove special characters except spaces from a string in PHP

1 Answer

0 votes
$s = "P$%H^%P C# JA!@#VA.";

$s = preg_replace('/[^A-Za-z0-9 ]/', '', $s);

echo $s;



/*
run:
  
PHP C JAVA
     
*/

 



answered Sep 19, 2019 by avibootz
...