Re: [PHP] reading txt file - certain lines
Dustin Krysak wrote: 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 What you can do (if you have access to a DB) is pull the text file into a single field table, using 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 ... i'm not quite sure, whether "" 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('', $variable) and you have lines in $lines... if "" 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... Now the contents of said text file would read something like the following: Liarby Sex Pistols"Never Mind The Bollocks"Played: 2004/07/28, 1:48:29 PM--Let's Rave Onby The Raveonettes"Chain Gang Of Love"Played: 2004/07/28, 1:46:37 PM--No Remorseby Metallica"Kill 'Em All"Played: 2004/07/28, 1:40:17 PM--This Is Our Emergencyby Pretty Girls Make Graves"The New Romance"Played: 2004/07/28, 1:36:37 PM--Freestylin'by Greyboy"Freestylin'"Played: 2004/07/28, 1:30:25 PM--In My Headby Naked Raygun"Raygun...Naked Raygun (Reissue)"Played: 2004/07/28, 1:26:37 PM--Lust To Loveby The Go-Go's"Return To The Valley Of The Go-Go's"Played: 2004/07/28, 1:23:13 PM--Kim You Bore Me To Deathby Grandaddy"Concrete Dunes"Played: 2004/07/28, 1:18:37 PM--Sonderkommandoby Gwar"This Toilet Earth"Played: 2004/07/28, 1:13:49 PM-- 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: 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... //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: Liarby Sex Pistols"Never Mind The Bollocks"Played: 2004/07/28, 1:48:29 PM--Let's Rave Onby The Raveonettes"Chain Gang Of Love"Played: 2004/07/28, 1:46:37 PM--No Remorseby Metallica"Kill 'Em All"Played: 2004/07/28, 1:40:17 PM--This Is Our Emergencyby Pretty Girls Make Graves"The New Romance"Played: 2004/07/28, 1:36:37 PM--Freestylin'by Greyboy"Freestylin'"Played: 2004/07/28, 1:30:25 PM--In My Headby Naked Raygun"Raygun...Naked Raygun (Reissue)"Played: 2004/07/28, 1:26:37 PM--Lust To Loveby The Go-Go's"Return To The Valley Of The Go-Go's"Played: 2004/07/28, 1:23:13 PM--Kim You Bore Me To Deathby Grandaddy"Concrete Dunes"Played: 2004/07/28, 1:18:37 PM--Sonderkommandoby Gwar"This Toilet Earth"Played: 2004/07/28, 1:13:49 PM-- 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]
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... Now the contents of said text file would read something like the following: Liarby Sex Pistols"Never Mind The Bollocks"Played: 2004/07/28, 1:48:29 PM--Let's Rave Onby The Raveonettes"Chain Gang Of Love"Played: 2004/07/28, 1:46:37 PM--No Remorseby Metallica"Kill 'Em All"Played: 2004/07/28, 1:40:17 PM--This Is Our Emergencyby Pretty Girls Make Graves"The New Romance"Played: 2004/07/28, 1:36:37 PM--Freestylin'by Greyboy"Freestylin'"Played: 2004/07/28, 1:30:25 PM--In My Headby Naked Raygun"Raygun...Naked Raygun (Reissue)"Played: 2004/07/28, 1:26:37 PM--Lust To Loveby The Go-Go's"Return To The Valley Of The Go-Go's"Played: 2004/07/28, 1:23:13 PM--Kim You Bore Me To Deathby Grandaddy"Concrete Dunes"Played: 2004/07/28, 1:18:37 PM--Sonderkommandoby Gwar"This Toilet Earth"Played: 2004/07/28, 1:13:49 PM-- 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
[PHP] reading txt file - certain lines
Hi there.. .I am displaying info (on music) from a text file with the following code... Now the contents of said text file would read something like the following: Liarby Sex Pistols"Never Mind The Bollocks"Played: 2004/07/28, 1:48:29 PM--Let's Rave Onby The Raveonettes"Chain Gang Of Love"Played: 2004/07/28, 1:46:37 PM--No Remorseby Metallica"Kill 'Em All"Played: 2004/07/28, 1:40:17 PM--This Is Our Emergencyby Pretty Girls Make Graves"The New Romance"Played: 2004/07/28, 1:36:37 PM--Freestylin'by Greyboy"Freestylin'"Played: 2004/07/28, 1:30:25 PM--In My Headby Naked Raygun"Raygun...Naked Raygun (Reissue)"Played: 2004/07/28, 1:26:37 PM--Lust To Loveby The Go-Go's"Return To The Valley Of The Go-Go's"Played: 2004/07/28, 1:23:13 PM--Kim You Bore Me To Deathby Grandaddy"Concrete Dunes"Played: 2004/07/28, 1:18:37 PM--Sonderkommandoby Gwar"This Toilet Earth"Played: 2004/07/28, 1:13:49 PM-- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php