Nathan Rixham wrote:
Robert Cummings wrote:
You may want to start testing your solutions. None have worked yet.
Not even close :)
filed under 'works for me'
<?php
$input = 'blah b asd as d
asd
a
sd
da
asd
d
asd
da';
echo preg_replace( "/(\s)\s+/im", '\\1', $input );
on PHP/5.2.8 produces:
blah b asd as d asd
a
sd
da asd
d
asd
da
unless I'm completely missing the elephant in the room here!
Doesn't appear to work on the following:
$input = '
1
2
3
4
5
6';
Additionally, your solution modifies lines that weren't asked to be
modified :) I realize it potentially makes for a more succinct solution
(if you ever get it to work properly in the general case) but it is not
a valid solution for the requested functionality-- The OP did not ask
for trimming of lines with content ;)
quote:
So in the file it would look like (from the original file the user uploads
that is)
1
2
3
4
5
6
but when the file is saved to the server it must look like
1
2
3
4
5
6
</quote>
the above produces what's required; and hence the vertical whitespace
only solution included too "/(\h)\h+/im"
what version are you on btw? not being an ass and actually am interested
in where it doesn't work (as I use the code on some important sites & in
some apps that are open sourced)
I think I see an issue... either my client, your client, both, or the
PHP list is trimming email lines. I have spaces at the end of some of
the lines in my example. Let's see if a text file attachment works for this.
FYI my command-line is currently running 5.2.11
Cheers,
Rob
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.
1
2
3
4
5
6
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php