Jump to content

[SOLVED] Help with parsing data in text file


speaker219

Recommended Posts

Hello. I was wondering if it was possible to parse the data in this text file.

http://207.210.102.183/tracker.txt

 

The information I want to be parsed is:

If you scroll down, to numbers 14-15, you'll see something like this:

The information I want parsed from that (This text file is constantly changing, but I'm almost certain the amount of lines in the file always stays the same.. e.g., the data changes, but it stays on the same line)

Is the bolded parts.

Any help would be greatly appreciated. Thanks a lot.

Signed, Total PHP Noob

EDIT: In case anyone is curious, the bolded part of the text file below is the Artist/Song Title for channels on Sirius Satellite Radio.

---

14

Classic Vinyl

Norman Greenbaum

Spirit In The Sky

Rock

$O3kI

yr

---

15

Classic Rewind

Rush

Limelight

Rock

$O95n

2Fs

---

Link to comment
Share on other sites

yes, but the data in that file isn't very consistent

 

use

file_get_contents

 

then explode it at the "\n- - -";

 

and then in each of those explode at the \n and you should get what you want,

 

so

 

<?php
$file = "http://207.210.102.183/tracker.txt";
$pointer = file_get_contents($file);
$data = explode("---",$pointer);
$data_bits = array();
foreach($data as $value){
$data_bits[] = explode("\n",$value);
}
print_r($data_bits);


?>

see what that does 4 you

 

Note I just fixed the delimieter

Link to comment
Share on other sites

yes, but the data in that file isn't very consistent

Yes, the data changes a lot, because it is songs changing on Sirius Satellite Radio.

But the structure always stays the same, and the only thing that should really change are the Artist and Song Name.

Thanks a lot though, I'm testing it out now.

Well, actually, I have to download apache and things to get a little testing station set up on this system, but I hope this works. Thanks again.

Link to comment
Share on other sites

Well, that sort of works, but I get a ton of output:

Array ( [0] => Array ( [0] => 11/12/2007 11:29:59 AM [1] => 1 [2] => Sirius Hits 1 [3] => The Last Goodnight [4] => Pictures Of You [5] => Pop [6] => $OU6V [7] => ZL [8] => ) [1] => Array ( [0] => [1] => 2 [2] => StarLite [3] => The Eagles [4] => How Long [5] => Pop [6] => $OAQo [7] => WR [8] => ) [2] => Array ( [0] => [1] => 3 [2] => Sirius Love [3] => Taylor Dayne [4] => Love Will Lead You Back [5] => Pop [6] => $O5Lu [7] => 18y [8] => ) [3] => Array ( [0] => [1] => 4 [2] => Movin EZ [3] => Rod Stewart [4] => You're In My Heart [5] => Pop [6] => $O8fl [7] => j [8] => ) [4] => Array ( [0] => [1] => 5 [2] => Sirius Gold [3] => Bobby Vinton [4] => There! I've Said It Again (1964) [5] => Pop [6] => $OEI7 [7] => fn [8] => ) [5] => Array ( [0] => [1] => 6 [2] => '60s Vibrations [3] => Cornelius Bros. & Sist [4] => Too Late To Turn Back [5] => Pop [6] => $O5hq [7] => B [8] => ) [6] => Array ( [0] => [1] => 7 [2] => Totally '70s [3] => Frankie Valli [4] => Grease (1978) [5] => Pop [6] => $OO0N [7] => #R [8] => ) [7] => Array ( [0] => [1] => 8 [2] => Big '80s [3] => Billy Joel [4] => Allentown (1983) [5] => Pop [6] => $O8g3 [7] => O [8] => ) [8] => Array ( [0] => [1] => 9 [2] => ThePulse [3] => Jesus Jones [4] => Right Here, Right Now (1991) [5] => Pop [6] => $OAA8 [7] => 1u [8] => ) [9] => Array ( [0] => [1] => 10 [2] => Bridge [3] => E Street Radio [4] => I Wanna Marry You [5] => Pop [6] => $O7CX [7] => 4ti [8] => ) [10] => Array ( [0] => [1] => 11 [2] => BBC Radio 1 [3] => BBC Radio 1 [4] => Jo Whiley [5] => Pop [6] => ^I [7] => [8] => ) [11] => Array ( [0] => [1] => 12 [2] => Super Shuffle [3] => Alan Jackson [4] => Chattahoochie [5] => Pop [6] => $O4E0 [7] => 5X [8] => ) [12] => Array ( [0] => [1] => 13 [2] => Elvis Radio [3] => Elvis Presley [4] => Anyplace Is Paradise (1956) [5] => Pop [6] => $ODLA [7] => [8] => ) [13] => Array ( [0] => [1] => 14 [2] => Classic Vinyl [3] => The Allman Brothers Band [4] => Jessica [5] => Rock [6] => $OW [7] => Qy [8] => ) [14] => Array ( [0] => [1] => 15 [2] => Classic Rewind [3] => Billy Squier [4] => Lonely Is The Night [5] => Rock [6] => $O8Ll [7] => 2Gz [8] => ) [15] => Array ( [0] => [1] => 16 [2] => TheVault [3] => The Who [4] => Bell Boy [5] => Rock [6] => $O9mW [7] => Vq [8] => ) [16] => Array ( [0] => [1] => 17 [2] => Jam_ON [3] => Dave Matthews Band [4] => One Sweet World [5] => Rock [6] => $OFb# [7] => 2h [8] => ) [17] => Array ( [0] => [1] => 18 [2] => Spectrum [3] => CAROL MILLER [4] => 1-877-33-SIRIUS [5] => Rock [6] => ^V [7] => [8] => ) [18] => Array ( [0] => [1] => 19 [2] => BuzzSaw [3] => Scorpions [4] => Rock You Like A Hurricane [5] => Rock [6] => $O647 [7] => 1Wv [8] => ) [19] => Array ( [0] => [1] => 20 [2] => Octane [3] => Black Light Burns [4] => Lie [5] => Rock [6] => $ONSA [7] => 3uy [8] => ) [20] => Array ( [0] => [1] => 21 [2] => Alt Nation [3] => Paramore [4] => Crushcrushcrush [5] => Rock [6] => $OIW9 [7] => 3eS [8] => ) [21] => Array ( [0] => [1] => 22 [2] => 1st Wave [3] => CALL RICHARD BLADE [4] => 1-877-33-SIRIUS [5] => Rock [6] => ^V [7] => [8] => ) [22] => Array ( [0] => [1] => 23 [2] => Hair Nation [3] => Bon Jovi [4] => Living In Sin [5] => Rock [6] => $OAYR [7] => 1vh [8] => ) [23] => Array ( [0] => [1] => 24 [2] => '90s Alternative [3] => Soundgarden [4] => Fell On Black Days [5] => Rock [6] => $O5u8 [7] => iw [8] => ) [24] => Array ( [0] => [1] => 25 [2] => Garage [3] => The Troggs [4] => Feels Like A Woman [5] => Rock [6] => $OC5A [7] => 1Fr [8] => ) [25] => Array ( [0] => [1] => 26 [2] => Left of Center [3] => Shout Out Louds [4] => Tonight I Have To Leave It [5] => Rock [6] => $OTiA [7] => I7 [8] => ) [26] => Array ( [0] => [1] => 27 [2] => Hard Attack [3] => Dragonforce [4] => Through The Fire And Flames [5] => Rock [6] => $OCcz [7] => 2eF [8] => ) [27] => Array ( [0] => [1] => 28 [2] => Faction [3] => The Crystal Method [4] => Busy Child [5] => Rock [6] => $O2h8 [7] => iP [8] => ) [28] => Array ( [0] => [1] => 29 [2] => Punk [3] => Bouncing Souls [4] => The BMX Song [5] => Rock [6] => $ORTw [7] => 6xi [8] => ) [29] => Array ( [0] => [1] => 30 [2] => The Coffee House [3] => Ryan Adams [4] => Nightbirds [5] => Rock [6] => $O9r6 [7] => 2ct [8] => ) [30] => Array ( [0] => [1] => 31 [2] => Margaritaville [3] => Club Trini [4] => No Woman, No Cry [5] => Rock [6] => $OK08 [7] => 22O [8] => ) [31] => Array ( [0] => [1] => 32 [2] => Sirius Disorder [3] => Grateful Dead Channel [4] => Truckin' [5] => Rock [6] => $OUI2 [7] => GO [8] => ) [32] => Array ( [0] => [1] => 33 [2] => Area 33 [3] => Ronski Speed f. Julie [4] => Love All The Pain Awa [5] => Elec/Dnc [6] => $O2cT [7] => 4yO [8] => ) [33] => Array ( [0] => [1] => 34 [2] => Boombox [3] => Kanye West vs. Wal [4] => Beethoven's Fith G [5] => Elec/Dnc [6] => $OUrl [7] => 4TJ [8] => ) [34] => Array ( [0] => [1] => 35 [2] => Chill [3] => The Chemical Brothers [4] => Seal [5] => Elec/Dnc [6] => $O27n [7] => 17e [8] => ) [35] => Array ( [0] => [1] => 36 [2] => The Beat [3] => Paul Oakenfold [4] => Faster Kill Pussycat [5] => Elec/Dnc [6] => $OOn8 [7] => 4Ln [8] => ) [36] => Array ( [0] => [1] => 37 [2] => Strobe [3] => Saint Tropez [4] => One More Minute [5] => Elec/Dnc [6] => $OKfZ [7] => 4OU [8] => ) [37] => Array ( [0] => [1] => 40 [2] => Hip-Hop Nation [3] => Jay-Z [4] => Roc Boys (And The Winner Is...) [5] => Hip-Hop [6] => $O3pD [7] => V_ [8] => ) [38] => Array ( [0] => [1] => 43 [2] => BackSpin [3] => Heavy D. and The Boyz [4] => Nuttin' But Love [5] => Hip-Hop [6] => $OMUA [7] => rV [8] => ) [39] => Array ( [0] => [1] => 45 [2] => Shade 45 [3] => SHOWDOWN- SPECIAL GUEST BOBBY CREEK! [4] => 888 SHADE 45 [5] => Hip-Hop [6] => [7] => [8] => ) [40] => Array ( [0] => [1] => 50 [2] => Hot Jamz [3] => Mary J. Blige [4] => Just Fine [5] => Hip-Hop [6] => $OVvo [7] => 5B [8] => ) [41] => Array ( [0] => [1] => 51 [2] => Heart & Soul [3] => Mary J. Blige [4] => Be Without You [5] => Hip-Hop [6] => $OKJM [7] => 5B [8] => ) [42] => Array ( [0] => [1] => 53 [2] => SoulTown [3] => Latimore [4] => Let's Straighten It Out [5] => Hip-Hop [6] => $O7#K [7] => op [8] => ) [43] => Array ( [0] => [1] => 60 [2] => New Country [3] => Eric Church [4] => Guys Like Me [5] => Country [6] => $OIoU [7] => 1pq [8] => ) [44] => Array ( [0] => [1] => 61 [2] => Prime Country [3] => Blake Shelton [4] => Austin [5] => Country [6] => $OEok [7] => 3G5 [8] => ) [45] => Array ( [0] => [1] => 62 [2] => Roadhouse [3] => Tom T. Hall [4] => A Week In A County Jail (1970) [5] => Country [6] => $O3C1 [7] => t7 [8] => ) [46] => Array ( [0] => [1] => 63 [2] => Outlaw Country [3] => Sir Douglas Quintet [4] => Mendocino [5] => Country [6] => $O31d [7] => zm [8] => ) [47] => Array ( [0] => [1] => 65 [2] => Bluegrass [3] => Russ Barenberg [4] => Jump Back Barley [5] => Country [6] => $O8cp [7] => 4QR [8] => ) [48] => Array ( [0] => [1] => 66 [2] => Spirit [3] => Chris Tomlin [4] => Amazing Grace [5] => Pop [6] => $OVKi [7] => 3ce [8] => ) [49] => Array ( [0] => [1] => 68 [2] => Praise [3] => Bishop Noel Jones [4] => Not About Us [5] => Hip-Hop [6] => $OVGt [7] => 4gL [8] => ) [50] => Array ( [0] => [1] => 70 [2] => Planet Jazz [3] => American Ambulance [4] => Hey! John Ashcroft [5] => JzzClscl [6] => $OOnK [7] => 8FQ [8] => ) [51] => Array ( [0] => [1] => 71 [2] => JazzCafe [3] => Dave Brubeck Quartet [4] => Take Five [5] => JzzClscl [6] => $OFw3 [7] => gV [8] => ) [52] => Array ( [0] => [1] => 72 [2] => PureJazz [3] => Billy Taylor & Ger [4] => Stompin' At The Sa [5] => JzzClscl [6] => $OUzR [7] => 4W9 [8] => ) [53] => Array ( [0] => [1] => 73 [2] => Spa 73 [3] => Bob Holroyd [4] => The Sheer Weight Of Memory [5] => JzzClscl [6] => $O10i [7] => 3Od [8] => ) [54] => Array ( [0] => [1] => 74 [2] => Blues [3] => Albert Collins [4] => Frosty [5] => JzzClscl [6] => $O1xp [7] => WF [8] => ) [55] => Array ( [0] => [1] => 75 [2] => Siriusly Sinatra [3] => Sue Raney [4] => Heart's Desire [5] => JzzClscl [6] => $OHjh [7] => 1yu [8] => ) [56] => Array ( [0] => [1] => 77 [2] => Broadway's Best [3] => Vivian Blaine [4] => Take Back Your Mink (19 [5] => JzzClscl [6] => $OVxs [7] => 433 [8] => ) [57] => Array ( [0] => [1] => 80 [2] => Symphony Hall [3] => Johannes Brahms [4] => Concerto for Vio [5] => JzzClscl [6] => $OBlp [7] => 7u [8] => ) [58] => Array ( [0] => [1] => 85 [2] => Met Opera Radio [3] => Felix Mendelssohn [4] => Neue Liebe, Op.19A [5] => JzzClscl [6] => $OCaz [7] => 8h2 [8] => ) [59] => Array ( [0] => [1] => 86 [2] => Sirius Pops [3] => Fritz Kreisler [4] => Liebesfreud [5] => JzzClscl [6] => $O6XB [7] => 8lx [8] => ) [60] => Array ( [0] => [1] => 90 [2] => Universo Latino [3] => RBD [4] => Inalcanzable [5] => Latn/Int [6] => $OFH9 [7] => SQ [8] => ) [61] => Array ( [0] => [1] => 92 [2] => Rumbon [3] => Gloria Estefan [4] => Me Odio [5] => Latn/Int [6] => $OF85 [7] => 13 [8] => ) [62] => Array ( [0] => [1] => 93 [2] => Bandeapart [3] => Galaxie 500 [4] => Galaxie 500 [5] => Latn/Int [6] => [7] => [8] => ) [63] => Array ( [0] => [1] => 94 [2] => CBC 3 [3] => Nathan Lawr and the Minotaurs [4] => Footsteps [5] => Rock [6] => [7] => [8] => ) [64] => Array ( [0] => [1] => 95 [2] => Iceberg [3] => M + M [4] => Black Stations/White Stations [5] => Rock [6] => [7] => [8] => ) [65] => Array ( [0] => [1] => 97 [2] => Reggae [3] => Mavado/Serani [4] => Dying [5] => Rock [6] => $OShv [7] => 2oq [8] => ) [66] => Array ( [0] => [1] => 100 [2] => Howard 100 [3] => The Wrap Up Show [4] => 888-STERN-100 [5] => Entrtain [6] => [7] => [8] => ) [67] => Array ( [0] => [1] => 101 [2] => Howard 101 [3] => Howard Stern Show [4] => West Coast Feed [5] => Entrtain [6] => [7] => [8] => ) [68] => Array ( [0] => [1] => 102 [2] => Sirius Stars [3] => Barbara Live ! [4] => Barbara Live ! [5] => Entrtain [6] => [7] => [8] => ) [69] => Array ( [0] => [1] => 103 [2] => Blue Collar Comedy [3] => Frank Caliendo [4] => Madden & Monday Night Football [5] => Entrtain [6] => !CG5t [7] => [8] => ) [70] => Array ( [0] => [1] => 104 [2] => Raw Dog Comedy [3] => Dan Naturman [4] => What's There To Do [5] => Entrtain [6] => !COAq [7] => [8] => ) [71] => Array ( [0] => [1] => 105 [2] => Laugh Break Comedy [3] => Laugh Break 105 [4] => 877-4-105-105 [5] => Family [6] => ^I [7] => [8] => ) [72] => Array ( [0] => [1] => 106 [2] => The Foxxhole [3] => The Jamie Foxx Show [4] => The Jamie Foxx Show [5] => Entrtain [6] => [7] => [8] => ) [73] => Array ( [0] => [1] => 107 [2] => E! Radio [3] => E News Weekend [4] => E News Weekend [5] => Entrtain [6] => [7] => [8] => ) [74] => Array ( [0] => [1] => 108 [2] => Maxim Radio [3] => COMEDIAN SHERYL UNDERWOOD [4] => CALL STRETCH 888-99-MAXIM [5] => Entrtain [6] => [7] => [8] => ) [75] => Array ( [0] => [1] => 109 [2] => OutQ Gay Radio [3] => Frank DeCaro / 866-305-688 [4] => W/ Wakefield Poole & Jim T [5] => Entrtain [6] => [7] => [8] => ) [76] => Array ( [0] => [1] => 110 [2] => Court TV Radio [3] => Best Defense [4] => Best Defense [5] => NewsTalk [6] => [7] => [8] => ) [77] => Array ( [0] => [1] => 111 [2] => Cosmo Radio [3] => BEST OF WAKE UP WITH COSMO RADIO [4] => BEST OF WAKE UP WITH COSMO RADIO [5] => Entrtain [6] => [7] => [8] => ) [78] => Array ( [0] => [1] => 112 [2] => Martha Stewart [3] => 1-866-675-6675 Call Sandy [4] => Share your Birthday Cake i [5] => Family [6] => [7] => [8] => ) [79] => Array ( [0] => [1] => 114 [2] => Lime [3] => The Lazy Environmentalist [4] => Call 1-866-LIME-114 [5] => Family [6] => [7] => [8] => ) [80] => Array ( [0] => [1] => 115 [2] => Radio Disney [3] => Drew Seeley [4] => Get'cha Head In The Game [5] => Family [6] => [7] => [8] => ) [81] => Array ( [0] => [1] => 116 [2] => Kids Stuff [3] => Dan Zanes And Friends [4] => Thrift Shop [5] => Pop [6] => $Ov_ [7] => 8Cv [8] => ) [82] => Array ( [0] => [1] => 118 [2] => Radio Classics [3] => John Kirby [4] => Effervescent Blues [5] => Family [6] => $O5bU [7] => [8] => ) [83] => Array ( [0] => [1] => 119 [2] => Discovery Radio [3] => Doctor Radio Launching Early '08 [4] => Doctor Radio Launching Early '08 [5] => Family [6] => [7] => [8] => ) [84] => Array ( [0] => [1] => 120 [2] => ESPN Radio [3] => ESPN Radio [4] => ESPN Radio [5] => Sports [6] => [7] => [8] => ) [85] => Array ( [0] => [1] => 121 [2] => ESPNEWS [3] => Midwest Insurance 888-549-2422 [4] => Midwest Insurance 888-549-2422 [5] => Sports [6] => [7] => [8] => ) [86] => Array ( [0] => [1] => 122 [2] => Sports 1 [3] => Rivals Radio (Replay) [4] => LIVE Mon-Fri 6am-9am ET on 123 [5] => Sports [6] => [7] => [8] => ) [87] => Array ( [0] => [1] => 123 [2] => Sirius Sports Action [3] => The Tony Bruno Show [4] => Call 888-441-TONY [5] => Sports [6] => [7] => [8] => ) [88] => Array ( [0] => [1] => 124 [2] => Sirius NFL Radio [3] => Movin' The Chains [4] => Call 877-NFL-KICK / 877-635-5425 [5] => Sports [6] => [7] => [8] => ) [89] => Array ( [0] => [1] => 125 [2] => Sports 2 [3] => English Premiership Replay [4] => Sunderland vs. Newcastle [5] => Sports [6] => [7] => [8] => ) [90] => Array ( [0] => [1] => 126 [2] => Sports 3 [3] => Monday / Tuesday on Sirius Sports [4] => Monday / Tuesday on Sirius Sports [5] => Sports [6] => [7] => [8] => ) [91] => Array ( [0] => [1] => 127 [2] => NBA [3] => NBA TV Simulcast [4] => NBA TV Simulcast [5] => Sports [6] => [7] => [8] => ) [92] => Array ( [0] => [1] => 128 [2] => Sirius NASCAR Radio [3] => Driver's Seat [4] => Call 866-PIT-LANE [5] => Sports [6] => [7] => [8] => ) [93] => Array ( [0] => [1] => 129 [2] => CNBC [3] => Barracuda.com 1-888-ANTI-SPAM [4] => Barracuda.com 1-888-ANTI-SPAM [5] => NewsTalk [6] => [7] => [8] => ) [94] => Array ( [0] => [1] => 130 [2] => Bloomberg Radio [3] => Bloomberg On The Money [4] => Bloomberg On The Money [5] => NewsTalk [6] => [7] => [8] => ) [95] => Array ( [0] => [1] => 131 [2] => Fox News [3] => Happening Now [4] => Happening Now [5] => NewsTalk [6] => [7] => [8] => ) [96] => Array ( [0] => [1] => 132 [2] => CNN [3] => CNN Newsroom [4] => CNN Newsroom [5] => NewsTalk [6] => [7] => [8] => ) [97] => Array ( [0] => [1] => 133 [2] => CNN Headline News [3] => Larry King (Replay) [4] => Larry King (Replay) [5] => NewsTalk [6] => [7] => [8] => ) [98] => Array ( [0] => [1] => 134 [2] => NPR Now [3] => The Bryant Park Project [4] => The Bryant Park Project [5] => NewsTalk [6] => [7] => [8] => ) [99] => Array ( [0] => [1] => 135 [2] => NPR Talk [3] => Diane Rehm [4] => Call 800-433-8850 [5] => NewsTalk [6] => [7] => [8] => ) [100] => Array ( [0] => [1] => 137 [2] => CBC 1 [3] => THE CURRENT [4] => www.cbc.ca/sirius [5] => NewsTalk [6] => [7] => [8] => ) [101] => Array ( [0] => [1] => 138 [2] => PremPlus [3] => Premiere + [4] => www.radio-canada/sirius [5] => Latn/Int [6] => [7] => [8] => ) [102] => Array ( [0] => [1] => 140 [2] => Sirius [3] => Radio Romania International [4] => World Radio Network [5] => NewsTalk [6] => [7] => [8] => ) [103] => Array ( [0] => [1] => 141 [2] => BBC News [3] => Analysis [4] => Analysis [5] => NewsTalk [6] => [7] => [8] => ) [104] => Array ( [0] => [1] => 143 [2] => ABC News & Talk [3] => Sirius [4] => Sirius [5] => NewsTalk [6] => [7] => [8] => ) [105] => Array ( [0] => [1] => 144 [2] => Patriot [3] => Mike Church Show [4] => Call 866-95-PATRIOT 866-957-2874 [5] => NewsTalk [6] => [7] => [8] => ) [106] => Array ( [0] => [1] => 145 [2] => Fox Talk [3] => Brian & The Judge [4] => 866-408-7669 [5] => NewsTalk [6] => [7] => [8] => ) [107] => Array ( [0] => [1] => 146 [2] => Left [3] => Alex Bennett [4] => Call 866-99-SIRIUS 866-997-4748 [5] => NewsTalk [6] => [7] => [8] => ) [108] => Array ( [0] => [1] => 147 [2] => Road Dog Trucking [3] => Did you see Trick My Truck [4] => Call Freewheelin': 1-888-8 [5] => Entrtain [6] => [7] => [8] => ) [109] => Array ( [0] => [1] => 148 [2] => NYC [3] => NY Weather [4] => NY Weather [5] => Traf/Wx [6] => *NYC [7] => [8] => ) [110] => Array ( [0] => [1] => 149 [2] => BOS-PHL [3] => Philadelphia Weather [4] => Boston in 4 mins. [5] => Traf/Wx [6] => *PHL [7] => [8] => ) [111] => Array ( [0] => [1] => 150 [2] => LA [3] => Los Angeles Weather [4] => Los Angeles Weather [5] => Traf/Wx [6] => *LA_ [7] => [8] => ) [112] => Array ( [0] => [1] => 151 [2] => CHI-StL [3] => St Louis Weather [4] => Chicago in 4 mins. [5] => Traf/Wx [6] => *STL [7] => [8] => ) [113] => Array ( [0] => [1] => 152 [2] => DC - BAL [3] => DC Traffic [4] => Baltimore in 4 mins. [5] => Traf/Wx [6] => *DC_ [7] => [8] => ) [114] => Array ( [0] => [1] => 153 [2] => ATL-MIA [3] => Miami Traffic [4] => Atlanta in 4 mins. [5] => Traf/Wx [6] => *MIA [7] => [8] => ) [115] => Array ( [0] => [1] => 154 [2] => DFW-HOU [3] => Houston Traffic [4] => Dallas in 4 mins. [5] => Traf/Wx [6] => *HOU [7] => [8] => ) [116] => Array ( [0] => [1] => 155 [2] => DET - LV [3] => Detroit Weather [4] => Las Vegas in 4 mins. [5] => Traf/Wx [6] => *DET [7] => [8] => ) [117] => Array ( [0] => [1] => 156 [2] => SF - SEA [3] => Seattle Traffic [4] => San Francisco in 4 mins. [5] => Traf/Wx [6] => *SEA [7] => [8] => ) [118] => Array ( [0] => [1] => 157 [2] => PHX-SD [3] => Phoenix Weather [4] => San Diego in 4 mins. [5] => Traf/Wx [6] => *PHX [7] => [8] => ) [119] => Array ( [0] => [1] => 158 [2] => ORL-TSP [3] => Tampa Weather [4] => Orlando in 4 mins. [5] => Traf/Wx [6] => *TSP [7] => [8] => ) [120] => Array ( [0] => [1] => 159 [2] => Catholic Channel [3] => Comedian Pat Cooper [4] => Call 888-322-8465 [5] => Family [6] => [7] => [8] => ) [121] => Array ( [0] => [1] => 160 [2] => EWTN [3] => Women of Grace (LIVE) [4] => 1-877-998-7884 [5] => Family [6] => [7] => [8] => ) [122] => Array ( [0] => [1] => 161 [2] => Christian Talk [3] => James Dobson Family Minute [4] => FamilyNet [5] => Family [6] => [7] => [8] => ) [123] => Array ( [0] => [1] => 181 [2] => ESPN Hispanic [3] => ESPN DEPORTES [4] => ESPN DEPORTES [5] => Sports [6] => [7] => [8] => ) [124] => Array ( [0] => [1] => 182 [2] => CNN en Espanol [3] => CNN en Espanol [4] => CNN en Espanol [5] => Latn/Int [6] => [7] => [8] => ) [125] => Array ( [0] => [1] => 183 [2] => Radio Korea [3] => Radio Korea [4] => Radio Korea [5] => Latn/Int [6] => [7] => [8] => ) [126] => Array ( [0] => [1] => 184 [2] => Weather/Emergency [3] => To Activate Call [4] => 1-888-539-SIRIUS [5] => Traf/Wx [6] => [7] => [8] => ) ) 

Sorry if i'm being a pain, but how would i just output the bolded data? I am a noob so i'm not sure. It's not just one array i don't think so i can't just do echo $array[150] or something like that...Sorry...but can you clarify about this? thanks.

Link to comment
Share on other sites

can I see the live link to it? or if not the print_r of it now

Here is the code you gave me

http://speaker.game-hackers.com/other/sirius.php

and the code rajivgonsalves gave me (kind of more what i want, but can't figure out how to get it to only show it for one channel/ one line)

http://speaker.game-hackers.com/other/sirius2.php

 

Thanks again

Link to comment
Share on other sites

try this

$strRun = file_get_contents("http://207.210.102.183/tracker.txt");


$arrRun = explode("---",$strRun);


function fnGetChannel($arrRun,$intChannel)
{
foreach ($arrRun as $strKey => $strValue)
{
	$arrData = explode("\n",$strValue);
	if (count($arrData) > 1 && $arrData[1]==$intChannel)
	{
		return  $arrData[3]."-".$arrData[4]."<BR>";
	}
}
}


print fnGetChannel($arrRun,25);

Link to comment
Share on other sites

Well, if you know exactly what data you want, then there's no need for all these foreach loops. Try:

 

<?php
$str = file_get_contents('http://207.210.102.183/tracker.txt');
$bits = explode('---',$str);
$station14 = $bits[13];//array key is one less than station number, since keys start from 0
$station15 = $bits[14];
$lines = explode("\n",$station14);//explode by the new line
$artist14 = $lines[3];//the lines we want are the third and fourth from each station
$track14 = $lines[4];
$lines = explode("\n",$station15);//repeat for station 15
$artist15 = $lines[3];
$track15 = $lines[4];
echo "Station 14<br />Artist: $artist14<br />Track: $track14<br /><br />Station 15<br />Artist: $artist15<br />Track: $track15";
?>

Link to comment
Share on other sites

rajivgonsalves, the one you gave me works perfectly. but i tried to have it say the artist - song for a channel specified in the url (e.g., sirius.php?chan=14)

But it just prints nothing no matter what i put!

this is the slightly modified code

<?php
$strRun = file_get_contents("http://207.210.102.183/tracker.txt");
$a = $_REQUEST['chan'];
$arrRun = explode("---",$strRun);


function fnGetChannel($arrRun,$intChannel)
{
foreach ($arrRun as $strKey => $strValue)
{
	$arrData = explode("\n",$strValue);
	if (count($arrData) > 1 && $arrData[1]==$intChannel)
	{
		return  $arrData[3]."-".$arrData[4]."<BR>";
	}
}
}


print fnGetChannel($arrRun, $a);
?>

But as you can see http://speaker.game-hackers.com/other/sirius3.php?chan=14 it prints nothing. suggestions??

EDIT: to clarify, it works if i just replace the $a in that with a channel num (e.g., 25)

Link to comment
Share on other sites

the problem with that is as I stated the data has inconsistencies will make them change from time to time so you either need to extract all the blank linkes, or find some solution to normalize it

I don't know what you're talking about...the same data always stays on the same lines and the total amount of lines never changes.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.