Alright I'm sure this is a rather n00bie question, but I've been searching and searching for the best/easiest way to do what I'm doing.
Here's what I'm doing:
I'm working on a template system. I've got most of it sorted out, the problem is I need to 'pull' tags off of the page.
Here's an example page:
<HTML>
<HEAD>
<TITLE>{&PAGE_TITLE&}</TITLE>
</HEAD>
<BODY TOPMARGIN='0' BOTTOMMARGIN='0' LEFTMARGIN='0' RIGHTMARGIN='0' BGCOLOR='#000000'>
{&INCLUDE_(header)&}
{&INCLUDE_(main_content)&}
{&INCLUDE_(footer)&}
</BODY>
</HTML>
So I need to pull all of the {&*&} tags out. Then return all of the tags that are on the page in any array.
Here's the code I'm working with:
<?php
$file = "<HTML>
<HEAD>
<TITLE>{&PAGE_TITLE&}</TITLE>
</HEAD>
<BODY TOPMARGIN='0' BOTTOMMARGIN='0' LEFTMARGIN='0' RIGHTMARGIN='0' BGCOLOR='#000000'>
{&INCLUDE_(header)&}
{&INCLUDE_(main_content)&}
{&INCLUDE_(footer)&}
</BODY>
</HTML>";
$pos = 0;
while ($pos < strlen($file)) {
$pos = strpos($file,"{&",$pos);
$pos+1;
$lastpos = strpos($file,"&}",$pos);
$tag = substr($file,$pos,$lastpos-$pos);
$pos = $lastpos+1;
$tagpos = $pos;
$pos = strpos($file,"{&",$pos);
$tag = substr($file,$tagpos,$pos-$tagpos);
$tags[] = trim($tag);
$pos = $lastpos+1;
}
echo count($links);
?>
Now I know I'm heading in the wrong direction with this, but the question is, which way is the right direction.
Any help is greatly appreciated.