Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $sites = site_list();
  4. $site_first = array();
  5. foreach($sites as $row) {
  6.     if(!array_key_exists($row['city'], $site_first)) {
  7.         $site_first[$row['city']] = array();
  8.     }
  9.     array_push( $site_first[$row['city']],$row );
  10. }
  11. //$i = 1;
  12.  
  13. $db=$site_first;
  14.  
  15. $columns=3;
  16. $count=count($db);
  17. $percol=intval(ceil($count/$columns));
  18.  
  19. $curcol=0;
  20. $curctr=0;
  21. foreach($db as $city)
  22. {
  23.    foreach($city as $site)
  24.    {
  25.       $td[$col][]=$site[1].'<br />'.$site[3].'<br />'.$site[8];
  26.       $curctr++;
  27.       if($curctr==$percol)
  28.       {
  29.         $curctr=0;
  30.         $curcol++;
  31.       }
  32.    }
  33. }
  34. echo "<table>".PHP_EOL;
  35. for($i=0;$i<$percol;$i++)
  36. {
  37.   echo " <tr>".PHP_EOL;
  38.   for($j=0;$j<$columns;$j++)
  39.     echo '    <td>'. (isset($td[$j][$i])?$td[$j][$i]:'&nbsp;') .'</td>'.PHP_EOL;
  40.   echo " </tr>".PHP_EOL;
  41. }
  42. echo "</table>".PHP_EOL;
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement