Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- // конвертер таблиц в html код, просто копируете таблицу в буфер обмена из любого источника и вставляете в поле ввода /skray/
- echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
- <html>
- <head>
- <title>csvhtml</title>
- <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">
- </head><body>
- <form method=POST >
- <textarea style=\"font-size:10px;FONT-FAMILY:arial; width:600px; height:500px;\" name=\"file\" >$post</textarea>
- <input type=\"hidden\" name=\"conv\" value=\"1\">
- <input type=\"hidden\" name=\"opi\">
- <input type=\"submit\" value=\"submit\">
- </form>
- </td><td valign=\"top\">";
- $file=isset($_POST['file'])?explode("\r\n",$_POST['file']):"";
- $count=count($file);
- echo'<!-- подсветка синтаксиса -->
- <script type="text/javascript" src="http://yandex.st/highlightjs/5.12/highlight.min.js"></script>
- <link rel="stylesheet" href="http://yandex.st/highlightjs/5.12/styles/vs.min.css" />
- <script type="text/javascript">
- hljs.initHighlightingOnLoad();
- </script>
- <!-- /подсветка синтаксиса -->
- ';
- echo "<pre><code><table><br>";
- for($i=0;$i<$count;$i++)
- {
- $ff=preg_replace("/\"/","",$file[$i]);
- $ff=preg_replace("/</","<",$ff);
- $ff=preg_replace("/>/",">",$ff);
- $td=explode("\t",$ff);
- $counttd=count($td);
- $fd="";$odd="";
- $fdr="<tr>";
- for($r=0;$r<$counttd;$r++)
- {
- $trm=$td[$r];
- $fd.=$trm;
- $fdr.="<td>$trm</td>";
- $odd.=$r==0?"<tr class=\"odd\"><td colspan=$counttd>$trm</td></tr><br>":"";
- }
- $fdr.="</tr><br>";
- $td0=trim($td[0]);
- $fd0=trim($fd);
- if(empty($td0)) continue;
- echo $fd0==$td0?$odd:$fdr;
- }
- echo "</table></code></pre>";
- echo' </td>
- </tr>
- </table>
- </body>
- </html>
- ';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment