473,396 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

help parsing linefeeds

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

Jul 12 '07 #1
1 1273
On Jul 12, 5:14 pm, "dino d." <dinodorr...@yahoo.comwrote:
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>

Jul 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
3
by: lino | last post by:
Hello, I have the following string: const char plaintext = "Fourscore and seven years ago our \ fathers brought forth upon this continent \ a new nation, conceived in liberty, and dedicated...
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
2
by: Grant Mills | last post by:
I'm trying to get linefeeds to display correctly in a datagrid (text is taken from a database of text that has been htmlencoded) By default it doesn't display them. But <br/> tags display fine. ...
1
by: Grant Mills | last post by:
I'm trying to get linefeeds to display correctly in a datagrid (text is taken from a database of text that has been htmlencoded) By default it doesn't display them. But <br/> tags display fine. ...
1
by: Lisa Bogart | last post by:
I am trying to take a string and parse it out into multiple strings based on a pattern but am stuck and am hoping someone can give me a clue. My pattern looks like so: sMatch =...
0
by: Kevin Hodgson | last post by:
I'm having a problem with System.Web.Mail.MailMessage losing linefeeds when creating an email. This is a VB.NET project. I use a stringbuilder to construct the MailMessage.Body and use vbCrLf...
3
by: Gina_Marano | last post by:
Hey All, There are many ways to skin a dog (I like cats so no cats) in .Net I have an XML string in the following format (without linefeeds): <remoteDir> <dir>MyDir</dir>...
2
by: embz | last post by:
this post concerns three pages. 1. this page: http://www.katherine-designs.com/sendemail.php i get the following errors: a lot of it seems to deal with the PHP code i inserted to the page....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.