1phpCopy<?php
2$searchString = " ";
3$replaceString = "";
4$originalString = "This is a programming tutorial";
5
6$outputString = preg_replace('/\s+/', '', $originalString);
7echo("The original string is: $originalString \n");
8echo("The string without spaces is: $outputString \n");
9?>
10
1phpCopy<?php
2$searchString = " ";
3$replaceString = "";
4$originalString = "This is a programming tutorial";
5
6$outputString = str_replace($searchString, $replaceString, $originalString);
7echo("The original string is: $originalString \n");
8echo("The string without spaces is: $outputString");
9
10?>
11