Houston, we have a problem,
Ok, heres the story, I am trying to build a script that parses a html txt document for <span class="????" name="????"> blah blah blah blah <b> blah </b> blah </span>. from this i need it to output 3 variable arrays ... or one sequencial variable. The variables being
- the class ???? bit
- the name ???? bit
- all the text between the <span> tags.
There will be more than one <span... </span> tag set in the document.
for some reason the ereg function works fine for one <span> tag but no more than that, after one it starts giving garbled results. i think it looks backwards for the </span> tag. any way, heres what i tried...
PHP:
<head>
<title>Test to search for variables in text file.</title>
</head>
<body>
im gonna scan test.html now, for span tags
<?php>
$filename = "test.html";
$fd = fopen ($filename, "rb");
$contents = fread ($fd, filesize ($filename));
ereg( '<span class=\"(.)\" name=\"(.)\">(.*)</span>', $contents, $data );
$size=count($data);
if (count($data)==0)
{
echo "no span tags found";
}
elseif (count($data)>0)
{
echo "found some tags <br>";
}
echo $size;
echo "<br>";
$row = 0;
while ($row<$size)
{
echo "------------ <br> $row ";
echo $data[$row];
echo "<br>" ;
$row=$row + 1;
}
?>
</body>
this is the sample text file, test.html
PHP:
<head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hey wassup</p>
<p>
<span class="text" name="first">
THis is in<b>side </b>a span tah</span></p>
<p>here is some ignore stuff</p>
<p><span class="text_sort" name="second">but i want you to find this !!!</span></p>
<p><span class="text" name="third"> but i want you to find this also !!!</span></p>
</body>
And it responds with....
im gonna scan test.html now, for span tags found some tags
10
0 THis is inside a span tah
here is some ignore stuff
but i want you to find this !!!
but i want you to find this also !!!
1 text" name="first"> THis is inside a span tah
here is some ignore stuff
but i want you to find this !!!
<span class="text
2 third
3 but i want you to find this also !!!
4
5
6
7
8
9
What it should respnd with is.... (hopefully)
im gonna scan test.html now, for span tags found some tags
10
------------
1 text
2 first
3 THis is in<b>side </b>a span tah
4 text_sort
5 second
6 but i want you to find this !!!
7 text
8 second
9 but i want you to find this also !!!
Any help would be appreciated, even if you think im going the compleatly wrong way abou this the TELL ME If you dont understand the question then TELL ME
Cheers Guys.