In PHP, ereg_replace is used to remove unwanted characters from a string. The code snippet below will remove all characters, such as @ and ! from a string.

PHP

<?php
$string = "Remove unwanted %% !character% from my string 2018&&";
$clean_string= ereg_replace("[^A-Za-z0-9]", "", $string);
echo $clean_string
?>

Run the code; the output should look like:

Remove unwanted character from my string 2018

 

Last modified: March 8, 2019

Comments

Write a Reply or Comment

Your email address will not be published.