On Nov 24, 2009, at 5:55 PM, Nirmalya Lahiri wrote:

--- On Wed, 11/25/09, aurfal...@gmail.com <aurfal...@gmail.com> wrote:

From: aurfal...@gmail.com <aurfal...@gmail.com>
Subject: [PHP] string concatenation with fgets
To: php-general@lists.php.net
Date: Wednesday, November 25, 2009, 7:00 AM
Hi all,

I'm trying to append some text to what I read from a file.

My code;

$file = fopen("foo.txt", "r");
while (!feof($file)) {
    $line = fgets($file);
    print $line."sometext";
    }
fclose($file);

foo,txt;
a
b
c
d
e
f
g

And when I run the script, it looks like;
a
sometextb
sometextc
sometextd
...


Any ideas?



So, what output you actually wants from your program?

Is it like this....
asometextbsometextcsometext......

or, like this....
asometext
bsometext
csometext



Hi,

Sorry, I was incomplete :)

I would like;

asometext
bsometext
csometext

Basically, I would like to add whatever text to the end of what I find in the file.

So if the file contains

a
b
c

I would like;

asometext
bsometext
csometext...

- aurf


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to