Jump to content

removing spaces and lines


mraza

Recommended Posts

Hi,

I am trying to parse a html page, but i get a lot of empty spaces, please any idea how can i remove spaces, here is my text:

         
        
          
this          goes here



   
   
     








one line here

  







some other line here









see there is a lot of space between text,

 

thanks for any help

Link to comment
Share on other sites

function replace_multiple_spaces($string)
{
// tabs, new lines and carriages are also replaced
$string = ereg_replace("[ \t\n\r]+", " ", $string);
return $string;
}
$string = "This
is
a   dummy
text. ";
$new_string = replace_multiple_spaces($string);
// Outputs: This is a dummy text
echo $new_string;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.