How to remove a specific character from a string in PHP…

To remove a character from a string, you can use the str_replace function.

<?php
$str = "Hello, World!";
$char = ",";
$newStr = str_replace($char, "", $str);
echo $newStr; // 输出 "Hello World!"
?>

In the example above, we achieved the removal of commas by using the str_replace function to replace the commas “,” in the string with an empty string.

bannerAds