Answers for "php remove unwanted characters from string"

PHP
5

php strip out special characters

function clean($string) {
   $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.

   return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
}
Posted by: Guest on December-09-2020
1

php regex remove characters from string

// not case sensetive replace
// use "/[..]/i" for case sensetivie result
$string = preg_replace("/[aeiou]/", '', $string);
Posted by: Guest on March-27-2021
2

php remove everything after symbol

$variable = substr($variable, 0, strpos($variable, "By"));
Posted by: Guest on December-02-2021

Code answers related to "php remove unwanted characters from string"

Browse Popular Code Answers by Language