Robson » Code » PHP » Code On Black

 
<?
   // syntax highlighted code is designed to be printed on a white background
   // this function changes the colours so they work with a black background
   function code_on_black($code)
   {
       return str_replace(
           array('<span style="color: #FF8000">',    // make the orange lighter (comments)
                   '<span style="color: #0000BB">',  // make the blue lighter (functions, variables)
                   '<span style="color: #007700">',  // make the green lighter (symbols, keywords)
                   '<span style="color: #DD0000">'), // make the red lighter (strings)
           array('<span style="color:#FB0">',
                   '<span style="color:#0BF">',
                   '<span style="color:#0E0">',
                   '<span style="color:#F00">'),
                   $code);
   }
   
   // example use
   echo code_on_black(highlight_file('my_news_system.php', 1));
?>
 
© 2004-17 robson | cc unless stated