|
Posted by ZeldorBlat on 07/12/07 21:54
On Jul 12, 5:14 pm, "dino d." <dinodorr...@yahoo.com> wrote:
> I need to parse a string by linefeeds and paragraphs. I need to
> preserve all periods and linefeeds too, so I can't simply use strtok
> or explode (both of which don't tell you where or which (period of lf)
> delimiter was found). So, I've written a function that tells me where
> the periods and linefeeds are. The problem is, I am having trouble
> figuring out what the character values are for the linefeed.
>
> For example, suppose I have this string:
>
> $text=
> "This is a sentence. I need to find linefeeds and periods.
>
> Sometimes a sentence will end in a period. Sometimes not
>
> I need to capture them all";
>
> So, basically, I need to grab all of the sentences, AND preserve the
> knowledge of where all the periods and line feeds are. But, it looks
> like I'm encountering multiple characters for a hard return. Which is
> strange, because simply comparing a character to "\n" is finding the
> locations of the hard returns fine. So two questions-
>
> 1) Is there a way to display the ASCII value of a char in PHP?
> 2) Is there an easy way to find and save the location of all of the
> hard returns?
>
> Thanks,
> Dino
As for #1, take a look at ord():
<http://www.php.net/ord>
[Back to original message]
|