Hi Folks.
I am looking to open an HTML document, search for the lines with 'HIDDEN' in the text.
Then, loop through and echo each instance of this search.
So far, I am able to open the document for reading, search for the string of text. But, I am getting stumped by looping through and grabbing all of the instances.
I can get it to work to the point of finding the first instance, but after that it stops. I am thinking that I have to stick it in an array, but my effort keeps on looping through and echoing the same line over and over in an endless loop.
I put the HTML code in a textarea, so you could see what I am searching.
I removed my attempt at the loop, as it would crash IE..heh heh.
Here is a link to view the code in action.
View Code in Action
Here is the code, any advice would be great:
<?php
#March 1, 2004
#Get current directory
$curDir = getcwd();
#echo $curDir; //-Debug
# Open the directory
$openDir = opendir($curDir);
# Loop through files in $curDir and find c.htm file
while(false!=($file=readdir($openDir)))
{
$cFile = substr($file,-5);
if($cFile=='c.htm')
{
#echo $file; //--Debug
#open file for reading only
$handle=fopen($file, "r");
#read file contents
$content = fread($handle, filesize("$file"));
#close file
fclose($handle);
#echo contents in textarea. Standard echo will not work, due to html code.
echo "<textarea cols='80' rows='10'>$content</textarea>";
$inputType = "HIDDEN";
$hiddenInputs = array(strstr($content, $inputType));
echo "<BR>".$hiddenInputs[0];
#Need to loop through all finds of HIDDEN and echo to screen.
}
}
?>