xxxxxxxxxx
<?php
$stripped = str_replace(' ', '', "10 1000 0000 000");
echo $stripped;
xxxxxxxxxx
$words = ' my words ';
$words = trim($words);
var_dump($words);
// string(8) "my words"
xxxxxxxxxx
$string = "this is my string";
$string = preg_replace('/\s+/', '', $string);
xxxxxxxxxx
phpCopy<?php
$searchString = " ";
$replaceString = "";
$originalString = "This is a programming tutorial";
$outputString = preg_replace('/\s+/', '', $originalString);
echo("The original string is: $originalString \n");
echo("The string without spaces is: $outputString \n");
?>
xxxxxxxxxx
<?php
$name = "Yeasin_ahammed_apon"
#str_replace('what u want to replace', 'with what ', $name);
str_replace('_', ' ', $name);
echo $name;
# output: Yeasin ahammed apon
?>
#str_replace('what u want to replace', 'with what ', $name);
xxxxxxxxxx
<?php
$string = "DelftStack is a best platform.....";
echo "Output: " . rtrim($string, ".");
?>
Output: DelftStack is a best platform
xxxxxxxxxx
phpCopy<?php
$searchString = " ";
$replaceString = "";
$originalString = "This is a programming tutorial";
$outputString = str_replace($searchString, $replaceString, $originalString);
echo("The original string is: $originalString \n");
echo("The string without spaces is: $outputString");
?>
xxxxxxxxxx
<?php
$mainstr = "@@PHP@Programming!!!.";
echo "Text before remove:\n" . $mainstr;
echo "\n\nText after remove: \n" . trim($mainstr, '@!.');
?>