| View previous topic :: View next topic |
| Author |
Message |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Sun Sep 07, 2008 8:39 pm Post subject: [PHP] Read file array |
|
|
How can i read a file line by line?
so...
----- welcome.txt ----
hey
hello
ohai thar
--------------------------
so $file[0] would output hey
$file[1] would output hello
$file[2] would output ohai thar
etc etc _________________
|
|
| Back to top |
|
 |
ElectroFusion Grandmaster Cheater
Reputation: 0
Joined: 17 Dec 2006 Posts: 786
|
Posted: Sun Sep 07, 2008 9:14 pm Post subject: |
|
|
I hate to inform you, but this is possible. I will spoonfeed you!
$string = fopen('file.txt', r);
$output = explode('\n', $string, -1));
echo $output;
But i'm not sure if this will work, unless you put \n at the end of each line.
Try it out and see.
EDIT : Fixed it. it said w but I changed it to r. _________________
| qwerty147 wrote: |
| ghostonline wrote: |
what world are you in?
|
bera
but i live in NZ
|
|
|
| Back to top |
|
 |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Sun Sep 07, 2008 9:20 pm Post subject: |
|
|
<?php
$string = fopen('C:\something.txt', r);
$output = explode('\n', $string, -1);
echo $output[0];
?>
outputs nothing. _________________
|
|
| Back to top |
|
 |
ElectroFusion Grandmaster Cheater
Reputation: 0
Joined: 17 Dec 2006 Posts: 786
|
Posted: Sun Sep 07, 2008 9:24 pm Post subject: |
|
|
Add me to msn and ill help you.
[email protected] _________________
| qwerty147 wrote: |
| ghostonline wrote: |
what world are you in?
|
bera
but i live in NZ
|
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Mon Sep 08, 2008 4:57 pm Post subject: |
|
|
u have to use 'r'
add the quotes... |
|
| Back to top |
|
 |
|