Re: [PHP] reading txt file - certain lines
Dustin Krysak wrote: snip Now what I want to do is read this file, but only say read 5 songs worth, then I would place the PHP code in (another table) and display the next 5 songs and so on This just allows for a more flexible layout in the final presentation. the way I am having the text files written, there is no way to get it to produce seperate text files - otherwise this would be easy to do snip What you can do (if you have access to a DB) is pull the text file into a single field table, using br as the line terminator. Looking at my MySQl book, for LOAD DATA, it says you can use a string to terminate the line. Then you can just run a simple query on the table (limited to the equivalent lines for 5 songs), and together with a loop, output the results. For big files, the DB will be faster and provides you with far greater flexibility HTH -- Rory McKinley Nebula Solutions +27 21 555 3227 - office +27 21 551 0676 - fax +27 82 857 2391 - mobile www.nebula.co.za This e-mail is intended only for the person to whom it is addressed and may contain confidential information which may be legally privileged. Nebula Solutions accepts no liability for any loss, expense or damage arising from this e-mail and/or any attachments. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reading txt file - certain lines
Everything is possible :) And in this case, it seems, that lines are delimited by br ... i'm not quite sure, whether br can be used in explode as a delimiter, if so, you have no problem and you just read all the file into variable, $lines = explode('br', $variable) and you have lines in $lines... if br can not be explode's parameter, i would use str_replace to replace it with ie. #13 and then explode it... or use some regular expressions... it depends on how fast you need it... :) hope this was what you needed... :) regards, m. Dustin Krysak wrote: Hi there.. .I am displaying info (on music) from a text file with the following code... ?php //open the file handler $fp02=fopen(assets/lib/php/itunes/recent.txt,r); //Read the track info $recent=fgets($fp02); //close the file. echo $recent; fclose($fp02); ? Now the contents of said text file would read something like the following: bLiar/bbrby ibSex Pistols/bibriNever Mind The Bollocks/ibrPlayed: 2004/07/28, 1:48:29 PMbr--brbLet's Rave On/bbrby ibThe Raveonettes/bibriChain Gang Of Love/ibrPlayed: 2004/07/28, 1:46:37 PMbr--brbNo Remorse/bbrby ibMetallica/bibriKill 'Em All/ibrPlayed: 2004/07/28, 1:40:17 PMbr--brbThis Is Our Emergency/bbrby ibPretty Girls Make Graves/bibriThe New Romance/ibrPlayed: 2004/07/28, 1:36:37 PMbr--brbFreestylin'/bbrby ibGreyboy/bibriFreestylin'/ibrPlayed: 2004/07/28, 1:30:25 PMbr--brbIn My Head/bbrby ibNaked Raygun/bibriRaygun...Naked Raygun (Reissue)/ibrPlayed: 2004/07/28, 1:26:37 PMbr--brbLust To Love/bbrby ibThe Go-Go's/bibriReturn To The Valley Of The Go-Go's/ibrPlayed: 2004/07/28, 1:23:13 PMbr--brbKim You Bore Me To Death/bbrby ibGrandaddy/bibriConcrete Dunes/ibrPlayed: 2004/07/28, 1:18:37 PMbr--brbSonderkommando/bbrby ibGwar/bibriThis Toilet Earth/ibrPlayed: 2004/07/28, 1:13:49 PMbr--br Now what I want to do is read this file, but only say read 5 songs worth, then I would place the PHP code in (another table) and display the next 5 songs and so on This just allows for a more flexible layout in the final presentation. the way I am having the text files written, there is no way to get it to produce seperate text files - otherwise this would be easy to do Is this possible? Thanks in advance! Dustin -- Miroslav Hudak developer designer http://hudak.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reading txt file - certain lines
Dustin Krysak wrote: Hi there.. .I am displaying info (on music) from a text file with the following code... ?php //open the file handler $fp02=fopen(assets/lib/php/itunes/recent.txt,r); //Read the track info $recent=fgets($fp02); //close the file. echo $recent; fclose($fp02); ? Now the contents of said text file would read something like the following: bLiar/bbrby ibSex Pistols/bibriNever Mind The Bollocks/ibrPlayed: 2004/07/28, 1:48:29 PMbr--brbLet's Rave On/bbrby ibThe Raveonettes/bibriChain Gang Of Love/ibrPlayed: 2004/07/28, 1:46:37 PMbr--brbNo Remorse/bbrby ibMetallica/bibriKill 'Em All/ibrPlayed: 2004/07/28, 1:40:17 PMbr--brbThis Is Our Emergency/bbrby ibPretty Girls Make Graves/bibriThe New Romance/ibrPlayed: 2004/07/28, 1:36:37 PMbr--brbFreestylin'/bbrby ibGreyboy/bibriFreestylin'/ibrPlayed: 2004/07/28, 1:30:25 PMbr--brbIn My Head/bbrby ibNaked Raygun/bibriRaygun...Naked Raygun (Reissue)/ibrPlayed: 2004/07/28, 1:26:37 PMbr--brbLust To Love/bbrby ibThe Go-Go's/bibriReturn To The Valley Of The Go-Go's/ibrPlayed: 2004/07/28, 1:23:13 PMbr--brbKim You Bore Me To Death/bbrby ibGrandaddy/bibriConcrete Dunes/ibrPlayed: 2004/07/28, 1:18:37 PMbr--brbSonderkommando/bbrby ibGwar/bibriThis Toilet Earth/ibrPlayed: 2004/07/28, 1:13:49 PMbr--br Now what I want to do is read this file, but only say read 5 songs worth, then I would place the PHP code in (another table) and display the next 5 songs and so on This just allows for a more flexible layout in the final presentation. the way I am having the text files written, there is no way to get it to produce seperate text files - otherwise this would be easy to do Is this possible? Yes, possible. Worth the time? No. Can you put all that info in a database? -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] reading txt file - certain lines
Yeah I do not really have the option to use a database here since the way the data is output is limited to a text file.. the files are populated by a program that takes the currently playing tracks out of Itunes (mp3 player) on my mac. d On 28-Jul-04, at 3:26 PM, [EMAIL PROTECTED] wrote: From: John Nichel [EMAIL PROTECTED] Date: July 28, 2004 2:05:51 PM PDT To: PHP [EMAIL PROTECTED] Subject: Re: [PHP] reading txt file - certain lines Dustin Krysak wrote: Hi there.. .I am displaying info (on music) from a text file with the following code... ?php //open the file handler $fp02=fopen(assets/lib/php/itunes/recent.txt,r); //Read the track info $recent=fgets($fp02); //close the file. echo $recent; fclose($fp02); ? Now the contents of said text file would read something like the following: bLiar/bbrby ibSex Pistols/bibriNever Mind The Bollocks/ibrPlayed: 2004/07/28, 1:48:29 PMbr--brbLet's Rave On/bbrby ibThe Raveonettes/bibriChain Gang Of Love/ibrPlayed: 2004/07/28, 1:46:37 PMbr--brbNo Remorse/bbrby ibMetallica/bibriKill 'Em All/ibrPlayed: 2004/07/28, 1:40:17 PMbr--brbThis Is Our Emergency/bbrby ibPretty Girls Make Graves/bibriThe New Romance/ibrPlayed: 2004/07/28, 1:36:37 PMbr--brbFreestylin'/bbrby ibGreyboy/bibriFreestylin'/ibrPlayed: 2004/07/28, 1:30:25 PMbr--brbIn My Head/bbrby ibNaked Raygun/bibriRaygun...Naked Raygun (Reissue)/ibrPlayed: 2004/07/28, 1:26:37 PMbr--brbLust To Love/bbrby ibThe Go-Go's/bibriReturn To The Valley Of The Go-Go's/ibrPlayed: 2004/07/28, 1:23:13 PMbr--brbKim You Bore Me To Death/bbrby ibGrandaddy/bibriConcrete Dunes/ibrPlayed: 2004/07/28, 1:18:37 PMbr--brbSonderkommando/bbrby ibGwar/bibriThis Toilet Earth/ibrPlayed: 2004/07/28, 1:13:49 PMbr--br Now what I want to do is read this file, but only say read 5 songs worth, then I would place the PHP code in (another table) and display the next 5 songs and so on This just allows for a more flexible layout in the final presentation. the way I am having the text files written, there is no way to get it to produce seperate text files - otherwise this would be easy to do Is this possible? Yes, possible. Worth the time? No. Can you put all that info in a database? -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED]