How to remove special characters 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:
  
PHPCJAVA
     
*/

 



answered Sep 19, 2019 by avibootz
...