Getting rid of extra lines

Getting rid of extra lines

am 29.07.2009 20:29:51 von tmiller

I am trying to get rid of empty whitespace lines, I can't us chop() because
as I read it it will remove all whitespaces....right?

Right now my db is outputting with extra lines, I have stripped tags I know
it isn't that causing it to look like this

Blahlajdlkfjlksdjflkdjsf

<--------------how do I get rid of all this extra space?

alkdfjlsdakjflsakdjflksjdf


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Getting rid of extra lines

am 29.07.2009 20:45:42 von Ashley Sheridan

[snip/]

Have you thought of just using a regular str_replace() on your code? You
can ask it to replace newlines and carriage returns with nothing and see
if that fixes you problem?

Thanks
Ash
www.ashleysheridan.co.uk


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Getting rid of extra lines

am 29.07.2009 20:48:40 von Bob McConnell

From: Miller, Terion

/* snip */

Before anyone can tell you how to fix it, you need to find out what is
causing that white space. is it empty lines, vertical tabs, thousands of
spaces, ...? Once you find that out, it is pretty easy to decide how to
get rid of them. Can you save the output to a file and open it with a
hex viewer?

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Getting rid of extra lines

am 29.07.2009 21:19:57 von List Manager

Miller, Terion wrote:
> I am trying to get rid of empty whitespace lines, I can't us chop() because
> as I read it it will remove all whitespaces....right?
>
> Right now my db is outputting with extra lines, I have stripped tags I know
> it isn't that causing it to look like this
>
> Blahlajdlkfjlksdjflkdjsf
>
> <--------------how do I get rid of all this extra space?
>
> alkdfjlsdakjflsakdjflksjdf
>
>

If the white space is included in data coming from the db you could run
a simple little regex on the variable to removed any repetitive white
space. But it might not be the best way to do it.

$clean = preg_replace('|\s+|', ' ', $input);
or
$clean = preg_replace('|\s{2,}|', ' ', $input);

If the white space is being generated in your HTML output, but is not in
your data store, then you need to cleanup your PHP code and that might help.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Getting rid of extra lines

am 29.07.2009 21:20:08 von tmiller

On 7/29/09 1:45 PM, "Ashley Sheridan" wrote:

[snip/]

Have you thought of just using a regular str_replace() on your code? You
can ask it to replace newlines and carriage returns with nothing and see
if that fixes you problem?

Thanks
Ash
www.ashleysheridan.co.uk



Yep I have tried str_replace to get rid of \n and it didn't work
Boss mentioned to explode the var that is full of so many blank lines then =
put it back together..seems like there has to be an easier way...

This is what I tried:

$tags =3D array('\n', '
'); $sNotes =3D str_replace($tags,"", $n=
otes);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Getting rid of extra lines

am 29.07.2009 21:23:43 von tmiller

On 7/29/09 2:19 PM, "Jim Lucas" wrote:

$clean =3D preg_replace('|\s+|', ' ', $input);

Hi Jim,
The extra whitespace lines are in the data store, coming from it I'm going =
to try your method but is there a way to not have mySQL store it with so ma=
ny lines (this is data being screen scraped and put in the db)
My code was at the beginning of this post of how I was inserting it.

Thanks
And Chocolate huh....
Terion

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Getting rid of extra lines

am 29.07.2009 21:37:14 von List Manager

Miller, Terion wrote:
>
>
> On 7/29/09 2:19 PM, "Jim Lucas" wrote:
>
> $clean = preg_replace('|\s+|', ' ', $input);
>
> Hi Jim,
> The extra whitespace lines are in the data store, coming from it I'm going to try your method but is there a way to not have mySQL store it with so many lines (this is data being screen scraped and put in the db)
> My code was at the beginning of this post of how I was inserting it.
>
> Thanks
> And Chocolate huh....
> Terion
>

If the method that I give you works on the out from the db to the
browser, the should be no reason you cannot adapt whatever script you
are using for scrapping to use this function when it inserts the data
into the db.

Jim


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Getting rid of extra lines

am 29.07.2009 22:05:16 von Jonathan Tapicer

On Wed, Jul 29, 2009 at 4:20 PM, Miller,
Terion wrote:
>
>
>
> On 7/29/09 1:45 PM, "Ashley Sheridan" wrote:
>
> [snip/]
>
> Have you thought of just using a regular str_replace() on your code? You
> can ask it to replace newlines and carriage returns with nothing and see
> if that fixes you problem?
>
> Thanks
> Ash
> www.ashleysheridan.co.uk
>
>
>
> Yep I have tried str_replace to get rid of \n and it didn't work
> Boss mentioned to explode the var that is full of so many blank lines the=
n put it back together..seems like there has to be an easier way...
>
> This is what I tried:
>
> =A0 =A0 $tags =3D array('\n', '
'); =A0 =A0$sNotes =3D str_replace($ta=
gs,"", $notes);
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

That didn't work because \n needs to be between " " instead of ' '.

Jonathan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Getting rid of extra lines (RESOLVED)

am 29.07.2009 22:14:01 von tmiller

On 7/29/09 3:05 PM, "Jonathan Tapicer" wrote:

On Wed, Jul 29, 2009 at 4:20 PM, Miller,
Terion wrote:
>
>
>
> On 7/29/09 1:45 PM, "Ashley Sheridan" wrote:
>
> [snip/]
>
> Have you thought of just using a regular str_replace() on your code? You
> can ask it to replace newlines and carriage returns with nothing and see
> if that fixes you problem?
>
> Thanks
> Ash
> www.ashleysheridan.co.uk
>
>
>
> Yep I have tried str_replace to get rid of \n and it didn't work
> Boss mentioned to explode the var that is full of so many blank lines the=
n put it back together..seems like there has to be an easier way...
>
> This is what I tried:
>
> $tags =3D array('\n', '
'); $sNotes =3D str_replace($tags,"", $=
notes);
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

That didn't work because \n needs to be between " " instead of ' '.

Jonathan


Thanks Guys, ended up using Jim's way before inserting it into the db and i=
t works like a charm


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Getting rid of extra lines (RESOLVED)

am 29.07.2009 22:16:20 von List Manager

Miller, Terion wrote:
>
>
> On 7/29/09 3:05 PM, "Jonathan Tapicer" wrote:
>
> On Wed, Jul 29, 2009 at 4:20 PM, Miller,
> Terion wrote:
>>
>>
>> On 7/29/09 1:45 PM, "Ashley Sheridan" wrote:
>>
>> [snip/]
>>
>> Have you thought of just using a regular str_replace() on your code? You
>> can ask it to replace newlines and carriage returns with nothing and see
>> if that fixes you problem?
>>
>> Thanks
>> Ash
>> www.ashleysheridan.co.uk
>>
>>
>>
>> Yep I have tried str_replace to get rid of \n and it didn't work
>> Boss mentioned to explode the var that is full of so many blank lines then put it back together..seems like there has to be an easier way...
>>
>> This is what I tried:
>>
>> $tags = array('\n', '
'); $sNotes = str_replace($tags,"", $notes);
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> That didn't work because \n needs to be between " " instead of ' '.
>
> Jonathan
>
>
> Thanks Guys, ended up using Jim's way before inserting it into the db and it works like a charm
>
>

Just to be clear. Can you paste which one worked for you.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Getting rid of extra lines (RESOLVED)

am 29.07.2009 22:18:35 von tmiller

On 7/29/09 3:16 PM, "Jim Lucas" wrote:

Miller, Terion wrote:
>
>
> On 7/29/09 3:05 PM, "Jonathan Tapicer" wrote:
>
> On Wed, Jul 29, 2009 at 4:20 PM, Miller,
> Terion wrote:
>>
>>
>> On 7/29/09 1:45 PM, "Ashley Sheridan" wrote:
>>
>> [snip/]
>>
>> Have you thought of just using a regular str_replace() on your code? You
>> can ask it to replace newlines and carriage returns with nothing and see
>> if that fixes you problem?
>>
>> Thanks
>> Ash
>> www.ashleysheridan.co.uk
>>
>>
>>
>> Yep I have tried str_replace to get rid of \n and it didn't work
>> Boss mentioned to explode the var that is full of so many blank lines th=
en put it back together..seems like there has to be an easier way...
>>
>> This is what I tried:
>>
>> $tags =3D array('\n', '
'); $sNotes =3D str_replace($tags,"", =
$notes);
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> That didn't work because \n needs to be between " " instead of ' '.
>
> Jonathan
>
>
> Thanks Guys, ended up using Jim's way before inserting it into the db and=
it works like a charm
>
>

Just to be clear. Can you paste which one worked for you.

This is what worked....on my page that inserts the data to the db I put

//stripping white line spaces $cleanNotes =3D preg_replace('|\s+|', ' '=
, $notes); $cleanVios =3D preg_replace('|\s+|', ' ', $cleanViolations);

then I mysql_escaped them and put them in the db, checked the csv and prest=
o perfect no extra linespacing


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php