Re: html parsing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ok I wrote something "quick and dirty" real quick:

But somehow it doesn't seem to like recursion. Is there something
"special" one needs to do in php ?

here's the code snippet:

function parsehtmlline($line)
{
if (strlen(strstr($line, "#include")) == 0 &&
    strlen(strstr($line, "<!--")) == 0) {
      /* nothing to parse just print it */
      print($line);
   }
else {
   /* extract the filename */
   $ssi = extractHTMLssi($line);

   /* open the file if it exists and output */
   /* it else just print the string         */
   if (file_exists($ssi)) {
      $incfile = fopen($ssi, "r");
      while (!feof($incfile)) {
         $ssiline = fgets($incfile, 1024);
// somehow PhP doesn't really like recursion, needs to be fixed
// for now just print the line.
//         parsehtmlline($ssiline);
         print($ssiline);
         }
      fclose($incfile);
      }
   else
      print($ssi);
   }
}

function extractHTMLssi($line)
{
$ssi = "";
$strptr = strstr($line, "\"");
if (strlen($strptr) == 0)
   return $line;
else
   {
   $ssi=$strptr;
   $iss=strrev($ssi);
   $strptr = strstr($iss, "\"");
   $iss = substr($strptr, 1, -1);
   $ssi = strrev($iss);
   }

return $ssi;
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux