php remove all whitespace from string code example
Example 1: remove empty spaces php
$string = str_replace(' ', '', $string);
Example 2: php remove all whitespace from a string
$whatonearth=preg_replace('/\s/','',"what o n ear th");
Example 3: Remove All Spaces Out of a String in PHP
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");
?>