Answers for "php remove symbols 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
0

Remove Special Character in PHP

phpCopy<?php
function RemoveSpecialChar($str)
{
    $res = preg_replace('/[0-9\@\.\;\" "]+/', '', $str);
    return $res;
}
$str = "My name is  hello and email [email protected];";
$str1 = RemoveSpecialChar($str);
echo "My UpdatedString: ", $str1;
?>
Posted by: Guest on April-23-2021
0

Remove special characters in php

function removeSpecialChar($string) 
		{
			$string = strtolower($string);
			$string = preg_replace('/[^\da-z ]/i', '', $string);// Removes special chars.
			$string = str_replace(' ', '-', $string); // Replaces all spaces with underscore.
			return strtolower($string);
		}
Posted by: Guest on December-27-2021
2

php remove everything after symbol

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

Remove Special Character in PHP

phpCopy<?php
$mainstr = "<h2>Welcome to <b>PHPWorld</b></h2>";

echo "Text before remove: \n" . $mainstr;

echo "\n\nText after remove: \n" .
    str_ireplace(array('<b>', '</b>', '<h2>', '</h2>'), '',
    htmlspecialchars($mainstr));
?>
Posted by: Guest on April-23-2021
0

remove % sign from string php

$string = str_replace('%', '', $string);
Posted by: Guest on January-06-2022

Code answers related to "php remove symbols from string"

Browse Popular Code Answers by Language