>I have a folder full of html pages that I need to extract the content
>from. They all have <!-- content start --> and <!--content end -->
>comment tags surrounding the content. I need an easy way (not one at a
>time) to extract that content and place it in a new template.
>
>Any ideas are appreciated. Im assuming it will have to be some sort of
>strpos and substr thing, but I'm not sure how to automate my process

You want to get rid of the comments, or preserve the comments?

If the former, a simple preg_replace() will help. See the documentation
here: http://php.net/preg_replace, http://php.net/pcre.pattern.syntax, and
http://php.net/pcre.pattern.modifiers. You will search for pieces of text
bounded by '<!--' and '-->' that can span multiple lines. You will also
want to set the not-greedy modifier, so you don't clobber things like:
'<!-- comment -->not a comment<!-- comment -->'.

If the latter, you can use the third argument to preg_match_all() to save
above-matching comments strings into an array. See the documentation here:
http://php.net/preg-match-all.

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca            http://mike.teczno.com/contact.html

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

Reply via email to