Advertisement
oxx93

Untitled

Aug 4th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.54 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="windows-1251">
  5. </head>
  6. <body>
  7. <?php
  8. $fp = fopen("http://gapi.ereality.ru/ores1.txt", "r");
  9.  
  10. $clanData = [];
  11. $resourceNames = [];
  12. $resourceId = 0;
  13. if ($fp) {
  14.     while(!feof($fp)) {
  15.         $line = fgets($fp, 999);
  16.         $line = trim($line);
  17.         if (!strlen($line)) {
  18.             break;
  19.         }
  20.         if ($line[0] != '#') {
  21.             list($clanId, $clanName, $mineName, $resourceAmount) = explode("|", $line);
  22.             if(!isset($clanData[$clanId])) {
  23.                 $clanData[] = [
  24.                     'clanId' => $clanId,
  25.                     'clanName' => $clanName,
  26.                     'mineName' => $mineName,
  27.                     'res' . $resourceId => $resourceAmount
  28.                 ];
  29.             } else {
  30.                 $clanData[$clanId]['res' . $resourceId] = $resourceAmount;
  31.             }
  32.         } else {
  33.             $resourceId++;
  34.             $resourceNames[$resourceId] = str_replace('#', '', $line);
  35.         }
  36.     }
  37. }
  38. fclose($fp);
  39.  
  40. echo '<table border="2">';
  41.     echo '<thead>';
  42.         echo '<tr>';
  43.         echo '<td>clanID</td>';
  44.         echo '<td>clanName</td>';
  45.         echo '<td>mineName</td>';
  46.             for ($i=1, $c=count($resourceNames);$i<=$c;$i++) {
  47.                 echo '<td><strong>'.$resourceNames[$i].'</strong></td>';
  48.             }
  49.         echo '<tr>';
  50.     echo '</thead>';
  51.     echo '<tbody>';
  52.     echo '<tr>';
  53.         echo '<td>'.$clanData['clanId'].'</td>';
  54.     echo '</tr>';
  55.     echo '</tbody>';
  56. echo '</table>';
  57. ?>
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement