Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

using file() and array_search()

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

using file() and array_search()

Postby 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
New php-forum User
 
Posts: 2
Joined: Thu Jan 16, 2003 11:42 am

Postby 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
New php-forum User
 
Posts: 2
Joined: Thu Jan 16, 2003 11:35 am

Postby 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
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: Google [Bot], Google Feedfetcher and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.