473,406 Members | 2,377 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,406 software developers and data experts.

getting text between two comments

I have access to a page that stores data as HTML. The code has two comments
around the data that I want to get called <!-- START --> and <!-- END -->

Question is, how do i read the page and grab the code that is between these
two comments

Nigel
Jul 17 '05 #1
3 6114
On 2004-01-12, Nigel <no****@here.com> wrote:
I have access to a page that stores data as HTML. The code has two comments
around the data that I want to get called <!-- START --> and <!-- END -->

Question is, how do i read the page and grab the code that is between these
two comments


You can find all your answers in the manual. http://www.php.net/manual

Opening, reading and closing a file -> file functions.
Finding something in a string -> string functions.
--
http://home.mysth.be/~timvw
Jul 17 '05 #2
To read the page, use file_get_contents(<filename>). To get the code use
preg_match(), like this:

if(preg_match('/<!-- START -->(.*)<!-- END -->/', $html, $matches)) {
$code = $matches[1];
}

Uzytkownik "Nigel" <no****@here.com> napisal w wiadomosci
news:bt*******************@news.demon.co.uk...
I have access to a page that stores data as HTML. The code has two comments around the data that I want to get called <!-- START --> and <!-- END -->

Question is, how do i read the page and grab the code that is between these two comments

Nigel

Jul 17 '05 #3
Oops, forgot the s modifier. Should be like this:

if(preg_match('/<!-- START -->(.*)<!-- END -->/s', $html, $matches)) {
$code = $matches[1];
}

Uzytkownik "Chung Leong" <ch***********@hotmail.com> napisal w wiadomosci
news:Bq********************@comcast.com...
To read the page, use file_get_contents(<filename>). To get the code use
preg_match(), like this:

if(preg_match('/<!-- START -->(.*)<!-- END -->/', $html, $matches)) {
$code = $matches[1];
}

Uzytkownik "Nigel" <no****@here.com> napisal w wiadomosci
news:bt*******************@news.demon.co.uk...
I have access to a page that stores data as HTML. The code has two

comments
around the data that I want to get called <!-- START --> and <!-- END -->
Question is, how do i read the page and grab the code that is between

these
two comments

Nigel


Jul 17 '05 #4

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

Similar topics

10
by: fotzor | last post by:
Hi, I'm a C++-Programmer and want to subclass the Edit used to write a SQL-Query in Access. The edit is of the special Access class OKttbx. Everything works, I injected a DLL into the...
26
by: Pravesh | last post by:
Hi: is there a way to get current system time in milliseconds... which functions and headers?? thanks pravesh
12
by: Sunny | last post by:
Hi All, I have a serious issue regarding classes scope and visibility. In my application, i have a class name "TextFile", and also a few other classes like "TotalWords", "TotalLines" and etc..,...
5
by: Ram [MSFT] | last post by:
Hi All, I'm trying to programatically (using c#) read the file properties (Title, Summary, Author, Comments etc.... The stuff that shows up on the Summary tab when you see the properties of a...
0
by: JT | last post by:
I have a web page that I want for the user to be able to enter their Name, address, Phone number, email, and comments and then click submit. I created a database with fields corresponding to the...
5
by: velu | last post by:
Problem in getting value from textbox & radiobuttonlist to a valuable inside a datagid. I want to insert a record into a table thru datagrid. Here is the code (see below) Private Sub...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
2
by: helraizer1 | last post by:
Hi folks, I have a script that pulls user comments from a database, which works fine. It's an image based script so I'm trying to now add emoticons, for such as =D or =) To do this I was...
9
by: KDawg44 | last post by:
Hi, I have PHP function that adds a record to the database. The table has an ID that is AUTO_INCREMENT. Is there anyway to get that ID back when I do any kind of insert? That ID is a foreign...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.