0) ? 'tab'.$tab : ''; // remove any tabs at the start of the line $line = str_replace("\t", '', $line); // find position of comment characters $slashslash_pos = strpos($line, '//'); $apos_pos = strpos($line, "'"); $slashstar_pos = strpos($line, '/*'); $starslash_pos = strLastPos($line, '*/'); // if it's an ongoing multi-line comment if ($multi_line_cmnt == 1) { $cmnt = 'cmnt'; $multi_line_cmnt = 1; } // if it's not an ongoing multi-line comment if ($multi_line_cmnt <> 1) { // if it's a single line comment if (($slashslash_pos === 0) || ($apos_pos === 0)) { $cmnt = 'cmnt'; $multi_line_cmnt = 0; } else { $cmnt = ''; $multi_line_cmnt = 0; } // if it's potentially the start of a multi-line comment if ($slashstar_pos === 0) { $cmnt = 'cmnt'; // if multi-line comment end string is found on the same line if ($starslash_pos == (strlen($line) - 3)) { $multi_line_cmnt = 0; } // if the multi-line comment end string is not found on the same line else { $multi_line_cmnt = 1; } } } // if the line contains the multi-line end string if ($starslash_pos == (strlen($line) - 3)) { $cmnt = 'cmnt'; $multi_line_cmnt = 0; } // if both cmnt and tab classes are to be applied if ( ($cmnt <> '') && ($tab <> '') ) { $class = ' class="'.$tab.' '.$cmnt.'"'; } // if only one class is to be applied else if ( ($cmnt <> "") || ($tab <> "") ) { $class = ' class="'.$tab.$cmnt.'"'; } // if no classes are to be applied else { $class = ''; } // remove return at the end of the line $line = str_replace("\n", "", $line); // if the line is blank, put a space in to stop some browsers collapsing the line if ($line == '') { // insert all the information and close the list item $list .= ' '."\n"; } // otherwise inserts the line contents else { // insert all the information and close the list item $list .= ''.$line.''."\n"; } } // close the finle handle fclose($file); // add in the link to the file $list .= '
  • Download this code: /'.$filename.'
  • '; // build the list $list = '
      '."\n".$list."\n".'
    '."\n"; // return the list return $list; } ?>