1

I'm trying to create a table of info about mods in a pack for a game server, I can parse the INI but can't figure out how to place it into an html table properly. the ini is:

[industrialcraft]
name = IndustrialCraft²
dev = Alblaka
website = http://www.industrial-craft.net
wiki = industrialcraft
[buildcraft]
name = BuildCraft
dev = SirSengir
website = http://www.mod-buildcraft.com/
wiki = buildcraft

I'm trying to get it into columns for the dev,website,etc. with headers at the top (name section doesn't need the header). and the wiki one is going to link to domain.com/wiki/bunchofstuff?id=insert_here I want it to look sort of like this:

                |   Dev   |         Official Website        |   Wiki Page
IndustrialCraft | Alblaka | http://www.industrial-craft.net | wiki link

I can manage the layout myself, but I figured I should specify in case it affects how it needs to be coded. I've been trying to figure it out myself but I'm still a bit of a noob with php..

5
  • 1
    checked php.net/manual/de/function.parse-ini-file.php yet? Commented Jun 26, 2013 at 16:51
  • @mplungjan thanks, I was just about to fix that format haha Commented Jun 26, 2013 at 16:51
  • @conceptdeluxe Yes, but thanks. I can parse the ini, I should have specified I need help getting it into a table. edited my question. Commented Jun 26, 2013 at 16:52
  • then may check this ... stackoverflow.com/questions/6010082/… ... :) Commented Jun 26, 2013 at 16:54
  • @conceptdeluxe that does help, thanks, but I still need to get the data from the parsed INI. I tried echoing and printing $ini_array[industrialcraft] with no luck :/ Commented Jun 26, 2013 at 17:11

1 Answer 1

2

Was that really hard?

<?php
  $datas  = parse_ini_file( $ini_file, true );
?>
<table border="1" cellspacing="0" cellpadding="5">
  <tbody>
    <?php
      foreach( $datas as $data ) {
    ?>
    <tr>
      <td rowspan="2"><?php echo htmlspecialchars( $data["name"] ); ?></td>
      <td>Dev</td>
      <td>Official Website</td>
      <td>Wiki Page</td>
    </tr>
    <tr>
      <td><?php echo htmlspecialchars( $data["dev"] ); ?></td>
      <td><?php echo htmlspecialchars( $data["website"] ); ?></td>
      <td>
        <a href="http://domain.com/wiki/bunchofstuff?id=<?php echo urlencode( $data["wiki"] ); ?>">wiki link</a>
      </td>
    </tr>
    <?php
      }
    ?>
  </tbody>
</table>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.