* @version 1.1.0 * @link http://aidanlister.com/repos/v/function.highlight_fiei.php * @param string $data The string to add line numbers to * @param bool $return return or echo the data * @param bool $linenum Add line numbers or not * @param bool $funclink Automatically link functions to the manual */ function highlight_filei($file, $return = false, $linenum = true, $funclink = true) { // Init $data = explode('
', file_get_contents($file)); $start = ''; $end = ''; $i = 1; $text = ''; // Loop foreach ($data as $line) { $text .= $start . $i . ' ' . $end . str_replace("\n", '', $line) . "
\n"; ++$i; } // Optional function linking if ($funclink === true) { $keyword_col = ini_get('highlight.keyword'); $manual = 'http://www.php.net/function.'; if (version_compare('5.0.0', PHP_VERSION) === -1) { $text = preg_replace( // Match a highlighted keyword '~([\w_]+)(\s*)'. // Followed by a bracket '(\s*\s*\()~m', // Replace with a link to the manual '$1$2$3', $text); } else { $text = preg_replace( // Match a highlighted keyword '~([\w_]+)(\s*)'. // Followed by a bracket '(\s*\s*\()~m', // Replace with a link to the manual '$1$2$3', $text); } } // Return mode if ($return === false) { echo $text; } else { return $text; } } ?>