I made a form that you submit a url to this script. This script opens the url and reads the file looking for particular text. The text I am looking for is like: <mytag name="blah" description="blah blah" /> . I have it to the point where I know the start and end positions of the tag, but how do I make the tag into a string that I can parse looking for the name and description?
<?php
$gw_open = "<mytag";
$gw_close = "/>";
//print submitted url out
print($url);
//open file
$handle = fopen ($url, "r");
//read file into string
while (!feof ($handle)) {
$buffer = fgets($handle, 4096);
$text = $text . $buffer;
}
//search for my tag
if (eregi($gw_open, $text)) {
echo "<br>page contains my tag!";
$pos1 = strpos($text, $gw_open);
echo "<br>pos = " . $pos1;
$pos2 = strpos($text, $gw_close, $pos1);
echo "<br>pos = " . $pos2;
//what do I do now???
}
fclose ($handle);
?>