Remove Multiple White Space From String Script

Remove Multiple White Space From String Script is use to remove all or some whitespace from a string, or compress multiple spaces in a string.

Demo :



Type Text  

Example :

Type Text :

"  php.ini is a configuration       file which controls         execution of the php program - it also control modules       supported eg: mysql module which is         needed to connect php code with mysql         database  "

Following code is used to multiple whitespace is removing from string if you need to copy and use your web site.


<?php
$str = "  php.ini is a configuration       file which controls         execution of the php program - it also control modules       supported eg: mysql module which is         needed to connect php code with mysql         database  ";

$newStr = ereg_replace('[[:space:]]+', ' ', trim($str));
echo $newStr;
?>

There are two steps involved in performing the above task. First, use the trim() function to delete the unnecessary whitespace from the ends of the string. Next, use the ereg_ replace() function to find multiple whitespace characters in the string and replace them with a single space.

The end result is a string with all extra whitespace removed. Alternatively, remove all the whitespace from a string, by altering the replacement string used by ereg_replace()

Free Download Script :

If you need remove multiple white space from string script click and download from following link.

Download




Content