Ask about general coding issues or problems here.
Moderators: macek, egami, gesf
by tbertz » Thu Jan 16, 2003 11:51 am
ok new to php and having some problems converting my head into the different way it handles things which is why:
$filename = "page.txt";
$lines=file('http://www.example.com');
$theline=$lines[0];
print $theline
doesnt work....
the way i understand it file() returns an array consisting of the lines within the file specified. I also thought that you could then refer to the line in question using [array.pos]?. Help I have managed to print the values contained withing the array, write the thing into the page and to a file.
However even with efforts using array_search I havent been able to pick out particualr phrases or strings.
Tom
-
tbertz
- New php-forum User

-
- Posts: 2
- Joined: Thu Jan 16, 2003 11:42 am
by Yellow-Box » Thu Jan 16, 2003 11:59 am
Try:
$array=file('example.txt');
echo $array[0];
works fine.
Jan.
-
Yellow-Box
- New php-forum User

-
- Posts: 2
- Joined: Thu Jan 16, 2003 11:35 am
by tbertz » Thu Jan 16, 2003 12:09 pm
that works fine with local files or maybe it the face that its a text file?? but it doesnt work with a url
-
tbertz
- New php-forum User

-
- Posts: 2
- Joined: Thu Jan 16, 2003 11:42 am
Return to PHP coding => General
Who is online
Users browsing this forum: Bing [Bot] and 3 guests