<?

// function2link(string) - Convert a PHP source code to HTML where the PHP-functions
//                         are turned into links to the PHP manual.
//
// () nicclas - www.frisim.com / www.nic-sys.se

function function2link( $str ) {

  $arrayFunctions = get_defined_functions();

  $sstr=preg_split("/(\W)/", $str,-1,PREG_SPLIT_DELIM_CAPTURE);

  for($j=0;$j<count($sstr);$j++) {

    if(strlen($sstr[$j])>2){
      for($i=0;$i<count($arrayFunctions['internal']);$i++){
        if(strcasecmp($arrayFunctions['internal'][$i],$sstr[$j])==0) {
          $sstr[$j] = "<a href=\"http://se.php.net/".$sstr[$j]."\" target=\"_blank\">".$sstr[$j]."</a>";
        }
      }
    }    
  }
  $all="";
  for($j=0;$j<count($sstr);$j++) {
    //$sstr[$j]=nl2br($sstr[$j]);
    $all.=$sstr[$j];
  }
  return $all;
}  

// get a web page into a string
$fcontents = implode ('', file ('syntaxlinking.php'));

$fcontents=htmlentities($fcontents);  // Konvertera typ <-tecken till &lt; f�r att f� HTML-korrekt i browsern
$fcontents=str_replace(" ","&nbsp;",$fcontents);   // Byt ut mellanslag mot &nbsp; f�r att indentering korrekt i browsern


echo "<pre>";
echo function2link($fcontents);
echo "</pre>";
?>