PHP Program to remove special characters from a string using preg_replace()

bookmark

<?php
    #string
    $str = 'We welcome all of you to our school (of PHP).
    This--> school is one of its kind :).
    Many schools dont offer this subject :(';
    
    $str = preg_replace('/[^A-Za-z0-9]/', '', $str);
    
    // Printing the result
    echo $str;
?>


Output
WewelcomeallofyoutoourschoolofPHPThisschoolisoneofitskindManyschoolsdontofferthissubject