Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function code($code)
- {
- /*
- *code_f0 = PHP open and Close tags
- *code_f1 = command
- * code_f2 = String ""
- * code_f3 = variable
- * code_f4 = Comment
- */
- $uj = $code;
- $uj = str_replace("class","<span class='code_f1'>class</span>",$uj);
- $uj = str_replace("if","<span class='code_f1'>if</span>",$uj);
- $uj = str_replace("for","<span class='code_f1'>for</span>",$uj);
- $uj = str_replace("while","<span class='code_f1'>while</span>",$uj);
- $uj = str_replace("print","<span class='code_f1'>print</span>",$uj);
- $uj = str_replace("do","<span class='code_f1'>do</span>",$uj);
- $uj = str_replace("function","<span class='code_f1'>function</span>",$uj);
- $uj = str_replace("foreach","<span class='code_f1'>foreach</span>",$uj);
- $uj = str_replace("<?php","<span class='code_f0'>".htmlentities("<?php")."</span>",$uj );
- $uj = str_replace("?>","<span class='code_f0'>".htmlentities("?>")."</span>",$uj);
- $uj = preg_replace("/(\")([a-zA-Z0-9 űáéúőóüöí]*)(\")/e", "'<span class=\'code_f2\'>\"\\2\"</span>'", $uj);
- $uj = preg_replace("/(\Ł)([a-zA-Z0-9]*)/e","'<span class=\"code_f3\">\$\\2 </span>'", $uj);
- $szoveg2 = array();
- $szoveg2 = explode("\n",$uj);
- $i=1;
- foreach($szoveg2 as $kulcs=>$kiir)
- {
- $szoveg2[$kulcs] = preg_replace("/([\/][\/])([a-zA-Z éáűőúöüóí,]*)/e","'<span class=\'code_f4\'>//\\2</span>'",$kiir);
- }
- echo "<table class='code_table' cellpadding='0' cellspacing='0'>";
- foreach($szoveg2 as $kiir)
- {
- if(($i%2)==0)
- {
- print "<tr>";
- print "<td class='one'>".$i."</td>";
- print "<td class='two'><code><pre>".$kiir."</pre></code></td>";
- print "</tr>";
- }
- else
- {
- print "<tr class='code_par'>";
- print "<td class='one'>".$i."</td>";
- print "<td class='two'><code><pre>".$kiir."</pre></code></td>";
- print "</tr>";
- }
- $i++;
- }
- echo "</table>";
- }
- ?>
Add Comment
Please, Sign In to add comment