Answers for "Remove Special Character in PHP"

PHP
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 Character in PHP

phpCopy<?php
$str = "@@HelloWorld";
$str1 = substr($str, 1);
echo $str1 . "\n\n";
$str1 = substr($str, 2);
echo $str1;
?>
Posted by: Guest on April-23-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 Special Character in PHP

phpCopy<?php
$string = "DelftStack is a best platform.....";
echo "Output:  " . rtrim($string, ".");
?>
Posted by: Guest on April-23-2021
0

Remove Special Character in PHP

phpCopy<?php
$str = "geeks";
$str = ltrim($str, 'g');
echo $str;
?>
Posted by: Guest on April-23-2021
0

Remove Special Character in PHP

phpCopy<?php
$mainstr = "@@PHP@Programming!!!.";
echo "Text before remove:\n" . $mainstr;
echo "\n\nText after remove: \n" . trim($mainstr, '@!.');
?>
Posted by: Guest on April-23-2021
0

Remove Special Character in PHP

phpCopy<?php
$mainstr = "This is a sim'ple text;";
echo "Text before remove: \n" . $mainstr, "\n";
$replacestr = remove_sp_chr($mainstr);
function remove_sp_chr($str)
{
    $result = str_replace(array("#", "'", ";"), '', $str);
    echo "\n\nText after remove: \n" . $result;
}
?>
Posted by: Guest on April-23-2021
0

Remove Special Character in PHP

phpCopy<?php
$str = "ei all, I said eello";
//$trans = array("h" => "-", "hello" => "hi", "hi" => "hello");
echo "Output:  " . strtr($str, "e", "h");
?>
Posted by: Guest on April-23-2021
0

Remove Special Character in PHP

phpCopy<?php
$strTemplate = "My name is :name, not :name2.";
$strParams = [
    ':name' => 'Dave',
    'Dave' => ':name2 or :password',
    ':name2' => 'Steve',
    ':pass' => '7hf2348', ];
echo "\n" . strtr($strTemplate, $strParams) . "\n";
echo "\n" . str_replace(array_keys($strParams), array_values($strParams), $strTemplate) . "\n";


?>
Posted by: Guest on April-23-2021

Code answers related to "Remove Special Character in PHP"

Browse Popular Code Answers by Language