Re: string concatenation with fgets
| From: | Nirmalya Lahiri | Date: | Wed, 25 Nov 2009 01:55:35 +0000 |
| Subject: | Re: string concatenation with fgets | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-300084@lists.php.net to get a copy of this message | ||
--- On Wed, 11/25/09, aurfalien@gmail.com <aurfalien@gmail.com> wrote:
> From: aurfalien@gmail.com <aurfalien@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
---
নির্মাল্য লাহিড়ী [Nirmalya Lahiri]
+৯১-৯৪৩৩১১৩৫৩৬ [+91-9433113536]