d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Php Grabbing Information From A File
Add Reply New Topic New Poll
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Jun 13 2012 06:09pm
My files current structure is
PlayerA;1;0;0
PlayerB;0;1;0

with php is it possible to grab that information from the file and display it on a website like
PlayerA | 1 Kill | 0 Deaths | 0 Assists
PlayerB | 0 Kill | 1 Deaths | 0 Assists

if so, how would i go about doing this?

I should also add, this data will be provided live, and I can't change the appearance of it at all, and will be used for a leader board
Member
Posts: 22,605
Joined: Sep 23 2007
Gold: 1.01
Warn: 40%
Jun 13 2012 08:21pm
Code
<html><had></head><body>
<table>

<?php
$file = file('bla.txt');
foreach ($file as $line) {
 echo '<tr>';
 $linedata = split(';', $line);
 foreach ($linedata as $x) {
   echo '<td>'.$x.'</td>';
 }
 echo '</tr>';
}
?>

</table>
</body></html>


i dont like that programming style (i prefer template and php in separate files), but it should give you an idea how to do it :)
this will just display the info from the input file, if you want to add "kill", "death", "assists" you just have to add them accordingly (replace the "foreach $linedata as $x" part with direct outputs of the table cells).

This post was edited by tcl on Jun 13 2012 08:24pm
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Jun 13 2012 08:35pm
Quote (tcl @ Jun 13 2012 09:21pm)
Code
<html><had></head><body>
<table>

<?php
$file = file('bla.txt');
foreach ($file as $line) {
 echo '<tr>';
 $linedata = split(';', $line);
 foreach ($linedata as $x) {
   echo '<td>'.$x.'</td>';
 }
 echo '</tr>';
}
?>

</table>
</body></html>


i dont like that programming style (i prefer template and php in separate files), but it should give you an idea how to do it :)
this will just display the info from the input file, if you want to add "kill", "death", "assists" you just have to add them accordingly (replace the "foreach $linedata as $x" part with direct outputs of the table cells).


thanks a bunch, very appreciated
Member
Posts: 219
Joined: Jun 8 2012
Gold: 96.00
Jun 14 2012 02:00am
I suggest you to learn what are design patterns (MVC), don't combine HTML with PHP : P

This post was edited by Perykles on Jun 14 2012 02:00am
Member
Posts: 512
Joined: Jun 20 2012
Gold: Locked
Trader: Scammer
Jun 21 2012 08:14am
nvmm
Member
Posts: 2,736
Joined: Nov 28 2009
Gold: 34.00
Jun 21 2012 04:01pm
Quote (Averno @ 21 Jun 2012 16:14)
nvmm


Nice spam

http://forums.d2jsp.org/user.php?i=912459&c=40&o=10
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll