Wednesday, 15 August 2012

html - Parse Section names from ini in PHP -



html - Parse Section names from ini in PHP -

i've been messing code night long, , haven't been able quite right, , unsure of search for.

here's i'm doing. using php parse .ini files html table.

here using in html file:

<?php $datas = parse_ini_string(file_get_contents( 'https://dl.dropboxusercontent.com/u/12345/test.ini' ), true); ?> <table border="1" cellspacing="0" cellpadding="5"> <tbody> <?php foreach( $datas $data ) { ?> <tr> <td rowspan="2"><?php echo htmlspecialchars( $data["name"] ); ?></td> <td>name</td> <td>points</td> </tr> <tr> <td><?php echo htmlspecialchars( $data["name"] ); ?></td> <td><?php echo htmlspecialchars( $data["points"] ); ?></td> </td> </tr> <?php } ?> </tbody> </table>

what show on table notated "section n" below:

[section 1] points=3 [section 2] points=173 [section 3] points=173

i unclear on how show "section n" in table, take next format:

section number | points section 1 | 3 section 2 | 173 section 3 | 173

any help or pointers appreciated! give thanks much!!

here code works, can utilize key section name.

<?php $datas = parse_ini_string(file_get_contents( 'http://hastebin.com/raw/ikovafilib' ), true); ?> <table border="1" cellspacing="0" cellpadding="5"> <tbody> <?php foreach( $datas $section => $data ) { ?> <tr> <td rowspan="2"><?php echo htmlspecialchars( $data["name"] ); ?></td> <td>name</td> <td>points</td> </tr> <tr> <td><?php echo htmlspecialchars( $section ); ?></td> <td><?php echo htmlspecialchars( $data["points"] ); ?></td> </td> </tr> <?php } ?> </tbody> </table>

edit: in future, when you're dealing array don't know output of, can utilize print_r() function debug outputs.

php html parsing ini

No comments:

Post a Comment