Current location: Hot Scripts Forums » Programming Languages » PHP » Stripping a text file and ceating some variables


Stripping a text file and ceating some variables

Reply
  #1 (permalink)  
Old 06-03-06, 07:46 PM
creepycridler's Avatar
creepycridler creepycridler is offline
Wannabe Coder
 
Join Date: Feb 2005
Location: Seatac, WA
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Stripping a text file and ceating some variables

Hello all!

I have a question and need some guidence. I have this text file that holds some variables and would like to extract those variables and use it with php so I can post some information to a web page.

The text file looks kinda like this:
Code:
"top 5"
{
  "1"
  {     
     "name"          "[J5]Dirrty.Magic"
     "wins"           "6"
     "steam"         "STEAM_0:1:6568839"
  }
  "2"
  {     
     "name"          "none"
     "wins"           "5"
     "steam"         "0"
  }
  "3"
  {     
     "name"          "none"
     "wins"           "4"
     "steam"         "0"
  }
  "4"
  {     
     "name"          "[J5]Coffie"
     "wins"           "4"
     "steam"         "STEAM_0:0:498830"
  }
  "5"
  {     
     "name"          "none"
     "wins"           "3"
     "steam"         "0"
  }
}
The text file will always be in this format with the "name", "wins", and "steam" fields changing. I want to be able to make a table with 5 rows and 3 columns like this:
1st name1 #wins
2nd name2 #wins
3rd name3 #wins
4th name4 #wins
5th name5 #wins

I need some suggestions of how to do this. Any help would be greatly appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-03-06, 08:17 PM
Breezy Breezy is offline
Newbie Coder
 
Join Date: Jun 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
I'll push you in a direction because I dont have any code right here right now that can do it... But I did have it somewhere, other computer. Anyways, involves implode() and explode() functions, a couple others as well. I wish I could help more.
__________________
TypoAuctions.com
Great deals via ebay typos... Never search eBay the same.


PolitiSource.com
Political & Current Event Discussion.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-07-06, 11:14 PM
ngcomputing's Avatar
ngcomputing ngcomputing is offline
Newbie Coder
 
Join Date: Jun 2006
Location: Florida
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
You can also format your text file into a CSV file then use fgetcsv() to parse it out -- in addition to the explode() function mentioned in the previous reply.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-07-06, 11:15 PM
ngcomputing's Avatar
ngcomputing ngcomputing is offline
Newbie Coder
 
Join Date: Jun 2006
Location: Florida
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Generating the source into an XML then parsing it with PHP would work well too.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 09:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.