EDIT: i was looking at the code and could it be because in the string there is a '/' because it gets in the if(<thetitle>) but not the if(</thetitle>) ? maybe
Is anyone familiar with the string tokenizer method.
I started doing my own approach..heres what i have:
<?php
$answer_check = 0;
$title_check = 0;
//opening the file
if (!($fp = fopen("file.txt", "r")))
exit("Unable to open the input file.");
$i=0;
while (!feof($fp))
{
$buffer = fgets($fp, 1024);
$buffarray[$i] = $buffer;
$i++;
}
fclose($fp);
//doinf the parsing
echo("Parsing!...");
for($j=0; $j < count($buffarray); $j++)// here we visit each string
{
$tok = strtok($buffarray[$j]," \n\t");//now through each string, current line
while ($tok)
{
if($tok == "<thetitle>")
{
$title_check = 1;
//echo("check is 1");
}
if($title_check == 1)
{
echo("<h1> $tok </h1>");
echo("printing element");
}
if($tok == "</thetitle>")
{
$title_check++;
//echo("check is 0 again");
}
$tok = strtok(" \n\t");
}
}
?>
My problem is that $title_check gets to = the value '1' but never gets set back to zero so it prints my whole markup language from <thetitle> on...
I just want to parse what is inside the <thetitle> tag to be html
am i using the tokenizer properly?
thanks