Re: regex help and file question

From: Date: Sat, 07 Aug 2004 19:53:47 +0000
Subject: Re: regex help and file question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-193097@lists.php.net to get a copy of this message
"Php Gen" <genphp@yahoo.com> wrote in message news:20040807192446.46370.qmail@web21525.mail.yahoo.com... > 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

« previous php.general (#193097) next »