Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
51
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.  
  14. $db=$site_first;
  15.  
  16. $columns=3;
  17. $count=count($db);
  18. $percol=intval(ceil($count/$columns));
  19.  
  20. $curcol=0;
  21. $curctr=0;
  22. foreach($db as $city)
  23. {
  24.    foreach($city as $site)
  25.    {
  26.       echo '<!-- '. print_r($site,TRUE) . '-->'.PHP_EOL;
  27.       $td[$curcol][]=$site[1].'<br />'.$site[3].'<br />'.$site[8];
  28.       $curctr++;
  29.       if($curctr==$percol)
  30.       {
  31.         $curctr=0;
  32.         $curcol++;
  33.       }
  34.    }
  35. }
  36. echo "<table>".PHP_EOL;
  37. for($i=0;$i<$percol;$i++)
  38. {
  39.   echo " <tr>".PHP_EOL;
  40.   for($j=0;$j<$columns;$j++)
  41.     echo '    <td>'. (isset($td[$j][$i])?$td[$j][$i]:'&nbsp;') .'</td>'.PHP_EOL;
  42.   echo " </tr>".PHP_EOL;
  43. }
  44. echo "</table>".PHP_EOL;
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement