Re: [PHP] .DAT file with PHP

2006-03-09 Thread Rory Browne
I didn't get the file, but If the lines are seperated by br's instead of newlines, then $filename = monkey.html; $file_array = preg_split(/br.*?/, file_get_content($filename)); $rev_array = array_reverse($file_array); $output = join(br /, $rev_array); This could be modded to maintain any

[PHP] .DAT file with PHP

2006-03-08 Thread Jabez
I want to use PHP to show the contents of the DAT from back to front. HOw do I do that? Thanks!

RE: [PHP] .DAT file with PHP

2006-03-08 Thread jblanchard
[snip] I want to use PHP to show the contents of the DAT from back to front. HOw do I do that? [/snip] Open the file, read it into an array, read the array backwards and close the file. Start with http://www.php.net/fopen and http://www.php.net/array they are both in the manual. -- PHP

RE: [PHP] .DAT file with PHP

2006-03-08 Thread Jabez Gan
@lists.php.net Subject: RE: [PHP] .DAT file with PHP [snip] I want to use PHP to show the contents of the DAT from back to front. HOw do I do that? [/snip] Open the file, read it into an array, read the array backwards and close the file. Start with http://www.php.net/fopen and http://www.php.net/array

Re: [PHP] .DAT file with PHP

2006-03-08 Thread Barry
Jabez Gan wrote: Sorry im new but, how do we read from a file to an array? I've studied C but not with PHP and it's not working for me... Suggestions? By line ? -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/)

Re: [PHP] .DAT file with PHP

2006-03-08 Thread M. Sokolewicz
]; php-general@lists.php.net Subject: RE: [PHP] .DAT file with PHP [snip] I want to use PHP to show the contents of the DAT from back to front. HOw do I do that? [/snip] Open the file, read it into an array, read the array backwards and close the file. Start with http://www.php.net/fopen and http

RE: [PHP] .DAT file with PHP

2006-03-08 Thread jblanchard
[snip] Sorry im new but, how do we read from a file to an array? I've studied C but not with PHP and it's not working for me... Suggestions? [/snip] First, read and understand, as much as possible, TFM. It should go something like this $foo = fopen(my.dat, r); while(!feof($foo)){ $bar =

RE: [PHP] .DAT file with PHP

2006-03-08 Thread Paul Novitski
At 07:41 AM 3/8/2006, Jabez Gan wrote: Sorry im new but, how do we read from a file to an array? I've studied C but not with PHP and it's not working for me... Suggestions? file() Reads entire file into an array http://php.net/file Doesn't require open close. Paul -- PHP General Mailing

Re: [PHP] .DAT file with PHP

2006-03-08 Thread Rory Browne
$filename = filename.txt; $file_content = join(\n, array_reverse(file($filename))); echo $file_content; Questions? BTW I haven't tested this, so it may be completely wrong. On 3/8/06, Paul Novitski [EMAIL PROTECTED] wrote: At 07:41 AM 3/8/2006, Jabez Gan wrote: Sorry im new but, how do

RE: [PHP] .DAT file with PHP

2006-03-08 Thread Jabez Gan
text came out when I do an echo $read What's wrong...? Thanks for your patience! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 08, 2006 11:50 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; php-general@lists.php.net Subject: RE: [PHP] .DAT file

Re: [PHP] .DAT file with PHP

2006-03-08 Thread Paul Novitski
At 10:27 AM 3/8/2006, Rory Browne wrote: $filename = filename.txt; $file_content = join(\n, array_reverse(file($filename))); echo $file_content; Rory, I think you've got the logic right. Tangentially, however, I recommend that you break it out into separate statements and not throw

Re: [PHP] .DAT file with PHP

2006-03-08 Thread Rory Browne
On 3/8/06, Paul Novitski [EMAIL PROTECTED] wrote: At 10:27 AM 3/8/2006, Rory Browne wrote: $filename = filename.txt; $file_content = join(\n, array_reverse(file($filename))); echo $file_content; Rory, I think you've got the logic right. Tangentially, however, I recommend that you break

Re: [PHP] .DAT file with PHP

2006-03-08 Thread Rory Browne
last mail got accidently sent before completion - please reply to that, or the OP and not this. I don't have much of a problem with code that takes a less blatent inspiration of the following: $file = filename.txt; $file = file_get_contents($file); $file = explode(\n, $file); $file =

RE: [PHP] .DAT file with PHP

2006-03-08 Thread Jabez
, March 09, 2006 2:58 AM To: php-general@lists.php.net Subject: Re: [PHP] .DAT file with PHP At 10:27 AM 3/8/2006, Rory Browne wrote: $filename = filename.txt; $file_content = join(\n, array_reverse(file($filename))); echo $file_content; Rory, I think you've got the logic right. Tangentially

RE: [PHP] .DAT file with PHP

2006-03-08 Thread Paul Novitski
At 07:05 PM 3/8/2006, Jabez wrote: I used the following code that Paul suggested, but it didn't reverse my content. The file I would want to have the content reversed is as attached. Chinese characters is in the file so... Suggestions? Jabez, The data in your file is all in one text line.