phpattributeshtml-parsingpreg-replacemeta-tags

Parse <meta> tag with specified attribute and extract another attribute's value


I'm working on an engine for my website. It's set up to use meta tags that PHP code then handles and creates the page, making it simple to create pages. I know a lot of people may think this is a bad way of processing things, but it's using dynamic paging to load pages. It will essentially load something like load.php?url=home, for example. Then load.php constructs the page if it exists on the server, if not we kill the page and result our 404.

The problem is, I'm using preg_replace() right now to get the value that is contained in the meta tags. This returns the page's PHP code.

All I want to do is get the result and then make the result a variable. I tried preg_filter() but that didn't seem to do anything.


Solution

  • You probably want preg_match and use the $matches array.