The last font tag (RegEx, maybe?)
Posted: Fri May 16, 2003 3:59 am
I'm wondering how on earth I would find the *last* <font> tag that doesn't have a </font> after it is... I can't seem to find a way to do it in Regex...
lil' help?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?PHP
$file = "source.php"; // Default page is always 1
if (isset($_GET['file']))
$file = $_GET['file']; // If the page number was requested via GET, use that
$php_self_array = explode("/",$_SERVER['PHP_SELF']);
// Directory Hack: http://127.0.0.1/filename.ext/arg becomes a valid and useful URL, with 'arg' being used for the page number
if (isset($php_self_array[2]) && $php_self_array[2]!="")
$file = $php_self_array[2]; // use the page number gathered from above
?>
<style>
<!--
.hahaha {font-family: Courier, 'Courier New', sans-serif; font-size: 11px;}
.lnum {font-family: Courier, 'Courier New', sans-serif; font-size: 11px; font-weight: 700; text-align:right;}
//--!>
</style>
<table>
<?php
$contents = highlight_file($file, true);
$contents = explode("<br />", $contents);
$ln = 1;
$g=array(array('',''),array('',''));
foreach($contents as $line) {
// array_reverse($g);
// print_r($g);
$line = '<font color="'.array_pop($g[1]).'">'.$line;
print '<tr><td class="lnum">'.$ln++.']</td><td class="hahaha">'.$line.'</td>';
preg_match_all('<font color="(#[0123456789AaBbCcDdEeFf]*)">',$line,$g);
}
?>
</table>