FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » finding newlines
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: finding newlines [message #183923 is a reply to message #183921] Mon, 25 November 2013 21:23 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
Denis McMahon wrote:

> A better mechanism may be:
>
> $lines=explode("\n",preg_replace("/[\r\n]+/","\n",$progressNote));
>
> Which will change all instances of any combination of one or more
> newlines and / or carriage returns to a single newline, and then split
> the string on the newline character.

$lines = preg_split('/[\\r\\n]+/', $progressNote);

or (having empty lines as empty-string array elements)

$lines = preg_split('/\\r?\\n|\\r/', $progressNote);

See also: <http://php.net/file>


PointedEars
--
When all you know is jQuery, every problem looks $(olvable).
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Lan Pc Login time
Next Topic: Check if $_GET contains something other than what's allowed
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 15:23:20 GMT 2024

Total time taken to generate the page: 0.03904 seconds