maexus Posted December 21, 2006 Share Posted December 21, 2006 http://ws.audioscrobbler.com/1.0/user/el_face/recenttracks.txtThat is the raw data I have to work with. All I'm trying to do is to explode new lines into an array and explode each line using the comma thats present after the timestamp. Here is the code I'm using:[code]$feed['txt'] = 'http://ws.audioscrobbler.com/1.0/user/'.USERNAME.'/recenttracks.txt';$file = file_get_contents($feed['txt']);foreach(explode('\n\r', $file) as $lines){ foreach(explode(',', $lines) as $tracks){ echo $tracks[1]."\n"; }}[/code]Seems like it would work. WRONG. I get this:1 e e e a a o o N r WNow, If I change echo $tracks[1]."\n" to echo $tracks."\n" it works just fine but still has the damn timestamp. Yes, I could parse the XML feed they have but you would think parsing text would be easier. Please help. Link to comment https://forums.phpfreaks.com/topic/31539-solved-parsing-a-simple-text-file-should-be-easy-is-it-no/ Share on other sites More sharing options...
trq Posted December 21, 2006 Share Posted December 21, 2006 [code]<?php$lines = file('http://ws.audioscrobbler.com/1.0/user/'.USERNAME.'/recenttracks.txt');foreach ($lines as $line) { $tmp = explode(',',$line); echo $tmp[1];}?>[/code] Link to comment https://forums.phpfreaks.com/topic/31539-solved-parsing-a-simple-text-file-should-be-easy-is-it-no/#findComment-146141 Share on other sites More sharing options...
maexus Posted December 21, 2006 Author Share Posted December 21, 2006 Ok, now I feel stupid. Thanks. Link to comment https://forums.phpfreaks.com/topic/31539-solved-parsing-a-simple-text-file-should-be-easy-is-it-no/#findComment-146142 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.