try - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of try.php
- <style>
- #link_content{font-weight:normal;margin:0 auto;width:650px;padding:10px;}
- #link_content table{border-collapse:collapse;margin:0px auto;}
- #link_content table td{ border:1px solid #075295; padding:5px;}
- #link_content table td:nth-child(1){width:550px;}
- #link_content table td:nth-child(2){width:100px;text-align:center;}
- #link_content .phead {padding:10px;font-weight:bold;text-align:center;background:#075295;color:white;}
- #link_content .link2{}
- #link_content .link2:hover{background:#ebebeb;cursor:pointer;}
- #link_content .link2 table{display:none;}
- #link_content .link2 div{display:none;}
- .highland{background:#ebebeb;font-weight:bold;}
- .colorBox div {text-align:center;}
- .colorBox hr{margin:5px;}
- .colorBox table{margin:10px auto;width:350px;border-collapse:collapse;text-align:center;font-weight:normal;}
- .colorBox table thead td{border:1px solid white;padding:30px 0px;font-size:18px;}
- .colorBox table tbody th { border:1px solid #075295; padding:10px;}
- .colorBox table tbody td { border:1px solid #075295; padding:5px;}
- .colorBox table th{background:#075295;color:white;}
- </style>
- <script>
- $(document).ready(function() {
- var procedura = $('<h3>Denumire procedura</h3><br/>');
- $('#link_content .link2').click(function(){
- var tbl = $(this).children().find('table');
- $.colorbox({
- inline:true,
- open:true,
- href:tbl,
- transition:"none",
- width:"600px",
- height:"500px",
- opacity: 0.5,
- fixed:true,
- className:"colorBox"
- });
- return false;
- });
- });
- </script>
- <?php
- $dir='achizitii_publice';
- //Returneaza continutul
- $link_content = dirToArray($dir,0,2);
- uksort($link_content,'cmp');
- $link_content=array2html($link_content);
- function cmp($a, $b){
- $a = date('Y-m-d', strtotime(str_replace('.','-',substr(end(explode('/',$a)),0,10))));
- $b = date('Y-m-d', strtotime(str_replace('.','-',substr(end(explode('/',$b)),0,10))));
- if ($a == $b) return 0;
- return ($a > $b) ? -1 : 1;
- }
- function dirToArray($dir,$pass,$stop){
- ++$pass;
- $contents = array();
- foreach (scandir($dir) as $node){
- if ($node == '.' || $node == '..') continue;
- if ($stop<$pass) continue;
- if (is_dir($dir . '/' . $node)){
- $contents[$dir.'/'.$node] = dirToArray($dir . '/' . $node,$pass,$stop);
- }else{
- $contents[] = $dir.'/'.$node;
- }
- }
- return $contents;
- }
- function array2ul($array){
- $out="<ul>";
- foreach($array as $key => $elem){
- if(!is_array($elem)){
- $info=pathinfo($elem);
- $name=basename($elem,'.'.$info['extension']);
- $out=$out."<li><a href='$elem' target='_blank'>$name</a></li>";
- }else{
- $key_name=end(explode('/',$key));
- if(count(current($array))>0){
- $out=$out."<li class='m' title='$key_name'>$key_name".array2ul($elem)."</li>";
- }else{
- $out=$out."<li class='link' title='$key'>$key_name".array2ul($elem)."</li>";
- }
- }
- }
- $out=$out."</ul>";
- return $out;
- }
- function array2html($array){
- $out="<table>";
- $i = 0;
- foreach($array as $key => $elem){
- if(!is_array($elem)){
- $title=substr(explode('/',$elem)[1],13);
- $info=pathinfo($elem);
- $dend=basename($elem,'.'.$info['extension']);
- $href='http://www.metrologieploiesti.ro/'.$elem;
- if ($i==0){
- $out=$out."<thead><tr><td>$title<hr></td></tr></thead><tr><th>Documente si clarificari</th></tr><tr class='detalii'><td><a href='$href' target='_blank'>$dend</a></td></tr>";
- }else{
- $out=$out."<tr class='detalii'><td><a href='$href' target='_blank'>$dend</a></td></tr>";
- }
- $i++;
- }else{
- $key_name=explode('/',$key);
- $key_name2=end($key_name);
- $datap=explode('-',$key_name2)[0];
- $denp=substr($key_name2,13);
- $out=$out."<tr class='link2' title='$denp'><td>$denp".array2html($elem)."</td><td>$datap</td></tr>";
- }
- }
- $out=$out."</table>";
- return $out;
- }
- ?>
- <div id="link_content">
- <table class="phead"><tr><td>Denumire achizitie</td><td>Data</td></tr></table>
- <?php echo $link_content; ?>
- </div>