Page 1 of 1
Array in file
Posted: Sun Jun 23, 2002 8:21 pm
by Jose Arce
Hi there, how can i convert the content of a file, to an element array, i mean, each line as an element...thanks

!
Posted: Sun Jun 23, 2002 8:32 pm
by Peter
Try the function,
file().

Posted: Sun Jun 23, 2002 8:32 pm
by will
you'll smack yourself after you see how easy it is ...
http://www.php.net/manual/en/function.file.php
Posted: Sun Jun 23, 2002 9:22 pm
by Jose Arce
Thx...i'm trying to make a foreach loop with the array..but it send me this error message:
Warning: Invalid argument supplied for foreach() in /home/sites/site187/users/arcelio/web/script.php on line 82
How can i make a foreach script?
Posted: Sun Jun 23, 2002 9:47 pm
by will
this would jsut print each line, but just do whatever you want with the line...
Code: Select all
$fileArray = file($filename);
foreach($fileArray as $line) {
echo $line;
}
Posted: Sun Jun 23, 2002 9:51 pm
by Jose Arce
all right!!!
Thx dude!