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 #183921 is a reply to message #183918] Mon, 25 November 2013 20:11 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Mon, 25 Nov 2013 11:12:17 -0500, bill wrote:

> I am trying to find the first line bread in a string where string =
> "Hand Carried by Patient\n\nTo Whom It May Concern:\n\nR...."
>
> This code does not work: $pos = strpos($progressNote,"\n\n");
> it returns pos = false
>
> where do I err?

If you're trying to find lines in a multiline string, you could try
splitting the string on newline characters:

$lines=explode("\n",$progressNote);

Then you can work through $lines looking for relevant ones.

Note that you may have some empty strings in $lines, and also that you
may have \r\n where you expect \n.

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.

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
[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: Wed Nov 27 20:10:15 GMT 2024

Total time taken to generate the page: 0.04494 seconds