Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="windows-1251">
- </head>
- <body>
- <?php
- $fp = fopen("http://gapi.ereality.ru/ores1.txt", "r");
- $clanData = [];
- $resourceNames = [];
- $resourceId = 0;
- if ($fp) {
- while(!feof($fp)) {
- $line = fgets($fp, 999);
- $line = trim($line);
- if (!strlen($line)) {
- break;
- }
- if ($line[0] != '#') {
- list($clanId, $clanName, $mineName, $resourceAmount) = explode("|", $line);
- if(!isset($clanData[$clanId])) {
- $clanData[] = [
- 'clanId' => $clanId,
- 'clanName' => $clanName,
- 'mineName' => $mineName,
- 'res' . $resourceId => $resourceAmount
- ];
- } else {
- $clanData[$clanId]['res' . $resourceId] = $resourceAmount;
- }
- } else {
- $resourceId++;
- $resourceNames[$resourceId] = str_replace('#', '', $line);
- }
- }
- }
- fclose($fp);
- echo '<table border="2">';
- echo '<thead>';
- echo '<tr>';
- echo '<td>clanID</td>';
- echo '<td>clanName</td>';
- echo '<td>mineName</td>';
- for ($i=1, $c=count($resourceNames);$i<=$c;$i++) {
- echo '<td><strong>'.$resourceNames[$i].'</strong></td>';
- }
- echo '<tr>';
- echo '</thead>';
- echo '<tbody>';
- echo '<tr>';
- echo '<td>'.$clanData['clanId'].'</td>';
- echo '</tr>';
- echo '</tbody>';
- echo '</table>';
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement