[PHP] Re: regex help and file question

2004-08-07 Thread Torsten Roehr
Php Gen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,
 I am just starting out with regex (and classes) so am
 not sure how to do this...

 I am seeing if a HTML file exists, if yes, I am using
 file_get_contents to get the entire HTML file into a
 string.

 In the HTML file I already have this:

 !-- Start header --
 html
 body
 whatever you want comes here
 !-- End header --

 How do I use a regex to span these multiple lines and
 simply cut everything (including the start..end
 part)from !-- Start header -- to !-- End header --

 Second question:
 I am using file_get_contents, is it better to use this
 than file() or fread() ?

 Thanks,
 Mag

Hi,

I can't answer your regexp question but some thoughts on file() etc.:
- file() returns the contents line by line as an array, so this makes only
sense if you need the contents in this form, e.g. for looping through each
line and applying a function or whatever
- fread() requires a file handle that you have to create with fopen(), so
file_get_contents() is kind of a shortcut for fopen()/fread()

Hope this helps.

Regards, Torsten Roehr

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: regex help and file question

2004-08-07 Thread PHP Gen

 Hi,
 
 I can't answer your regexp question but some
 thoughts on file() etc.:
 - file() returns the contents line by line as an
 array, so this makes only
 sense if you need the contents in this form, e.g.
 for looping through each
 line and applying a function or whatever
 - fread() requires a file handle that you have to
 create with fopen(), so
 file_get_contents() is kind of a shortcut for
 fopen()/fread()
 

Hey,

Thanks for replying and the answer to my second Q,
sounds like file_get_contents() is good for me now.

I think i found a solution for the regex too, just
have to modify some parts.

Cheers,
Mag

=
--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)




__
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php