473,804 Members | 3,019 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

parsing and displaying a text file

3 New Member
Hello all, I am having a problem displaying a txt file I have. I have code to parse it but I do not know how to display the information.

The code I have is:
[PHP]<?php
// Process server data
if ( $fdsStatusTXT = file_get_conten ts ( "fdsstatus. txt" ) )
{
$fdsStatusArray = explode ( "\n", $fdsStatusTXT );
// Create gameData array
$gameData = array (
'mode' => $fdsStatusArray[0],
'map' => $fdsStatusArray[1],
'gdi_players' => $fdsStatusArray[2],
'gdi_points' => $fdsStatusArray[3],
'nod_players' => $fdsStatusArray[4],
'nod_points' => $fdsStatusArray[5],
'max_players' => $fdsStatusArray[6],
'timeleft' => $fdsStatusArray[7],
'sfps' => $fdsStatusArray[8]
);

// Create playerData array
for ( $i = 0; $i < $gameData['gdi_players']+$gameData['nod_players']; $i++ )
{
// Explode the appropriate index of $fdsStatusArray into itself
$fdsStatusArray[$i+9] = explode ( "\t", $fdsStatusArray[$i+9] );

// Adjust time field
$fdsStatusArray[$i+9][6] = substr ( $fdsStatusArray[$i+9][6], strpos( $fdsStatusArray[$i+9][6], "." )+1 );
$playerData[$i] = array (
'name' => trim($fdsStatus Array[$i+9][0]),
'side' => trim($fdsStatus Array[$i+9][1]),
'score' => trim($fdsStatus Array[$i+9][2]),
'kills' => trim($fdsStatus Array[$i+9][3]),
'deaths' => trim($fdsStatus Array[$i+9][4]),
'ping' => trim($fdsStatus Array[$i+9][5]),
'time' => trim($fdsStatus Array[$i+9][6])
);
}
}
?>[/PHP]
Jan 19 '08 #1
3 1319
Atli
5,058 Recognized Expert Expert
Hi. Welcome to TSDN!

You may want to take a look at the print_r() function. It's good if you only want to see the contents of an array without any fancy tables and such.

I'm not really sure what you want to do with all that information there.
The code you posted will parse it into arrays, the only thing you would have to do is print it into whatever format you want to view it in.

If you give us a little more info on what exactly you are trying to do, and maybe how much PHP experience you have, we may be able to give you more helpful answers.
Jan 19 '08 #2
comatose28
3 New Member
I have some phh experience (2 years self taught) and I want to display this in 2 ways: one in a php page that will just display the info (tables not needed) and one in a php page that acts as an image.
Jan 20 '08 #3
Atli
5,058 Recognized Expert Expert
Ok.

If you just want the info, nothing fancy, in your PHP page, just do something like this:
Expand|Select|Wrap|Line Numbers
  1. echo "<pre>". print_r($myArray, true) ."</pre>";
  2.  
To put it into an image, you would probably want to use the Image Functions. Check out the example on the page there. You probably want something similar to that.
Jan 21 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2865
by: Joe Price | last post by:
Hi chaps I've got an XML file, within that file i've embedded html code using the <!]> tag I'm displaying that xml file through a browser using an xsl style sheet. However it is displaying any html from the xml file as text, ie its displaying as text <br/> and <b> etc
4
2660
by: ralphNOSPAM | last post by:
Is there a function or otherwise some way to pull out the target text within an XML tag? For example, in the XML tag below, I want to pull out 'CALIFORNIA'. <txtNameUSState>CALIFORNIA</txtNameUSState>
3
3509
by: Pir8 | last post by:
I have a complex xml file, which contains stories within a magazine. The structure of the xml file is as follows: <?xml version="1.0" encoding="ISO-8859-1" ?> <magazine> <story> <story_id>112233</story_id> <pub_name>Puleen's Publication</pub_name> <pub_code>PP</pub_code> <edition_date>20031201</edition_date>
2
1878
by: Andy | last post by:
Hi guys, I'm writing a program with a feature of accepting user input as command text and parsing it to correct function calls...example: "5 minutes later"/"5 min later"/"5 minute later"/"after 5 minutes"... are being parsed as the same rule so the system will call a later function with minutes=5 as parameter. Of course there are many other possiblilities, "seconds"/"days", and
3
4389
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in the file) with the location. And for a particular section I parse only that section. The file is something like, .... DATAS
6
1566
by: sukiu47 | last post by:
I have one text file . I having a problem to read multiple lines in text file my Text file A { A20 = { { 11, 32, 96, 33, 28 }, { 22, 23, 45, 23, 22 },
13
4522
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple command set consisting of several single letter commands which take no arguments. A few additional single letter commands take arguments:
2
2668
by: nicky123 | last post by:
Hi everyone, This is a brief description that I have provided for parsing & displaying an XML document using DOM API. Please feel free to post your own comments & views regarding this discussion. Thank you. The first step of parsing an XML document is to import the DOM API related classes such as :- java.io.* which contains all the interfaces to perform an I/O operation. org.xml.sax.* which contains all the interfaces...
1
4856
by: avpkills2002 | last post by:
I seem to be getting this weird problem in Internet explorer. I have written a code for parsing a XML file and displaying the output. The code works perfectly fine with ffx(Firefox).However is not working in Internet Explorer.(I m using Internet Explorer 6.0). The code is as follows: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html...
0
9575
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10320
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10073
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6846
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.