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 's instead of newlines, then $filename = "monkey.html"; $file_array = preg_split("//", file_get_content($filename)); $rev_array = array_reverse($file_array); $output = join("", $rev_array); This could be modded to maintain any arguments in

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.

RE: [PHP] .DAT file with PHP

2006-03-08 Thread Jabez
rsday, 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

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 = array_re

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 reco

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 mult

RE: [PHP] .DAT file with PHP

2006-03-08 Thread Jabez Gan
However, only "Array" 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.p

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

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 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 M. Sokolewicz
PROTECTED]; 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/fope

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/) To

RE: [PHP] .DAT file with PHP

2006-03-08 Thread Jabez Gan
hp-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://www.php

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 Gen

[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!