FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP Read File Help needed.





The-Master
Please help. I am trying to load a file from a website which will then echo a certain line or lines which I specify.

The file function in the PHP manual is here but I don't know how to do what I am wanting. I hope all you smart people can help! Thanks. Smile
hexkid
The-Master wrote:
Please help. I am trying to load a file from a website which will then echo a certain line or lines which I specify.
Code:
<?php
// read the file
$f = file('http://www.example.com/');
// echo lines 5, 8, and 42
echo trim($f[4]), "<br>\n";
echo trim($f[7]), "<br>\n";
echo trim($f[41]), "<br>\n";
?>
The-Master
Wow! Thanks very much. It looks so easy now you have shown me it and I feel stupid now Smile

One last question. How would I make the text automatically go onto a new line after so many characters only during a space. Thanks very much.
ashok
The-Master wrote:
Wow! Thanks very much. It looks so easy now you have shown me it and I feel stupid now Smile

One last question. How would I make the text automatically go onto a new line after so many characters only during a space. Thanks very much.


The output automatically goes to a new line... If it's not, just put the echo output in between <p> tags..
hexkid
The-Master wrote:
How would I make the text automatically go onto a new line after so many characters only during a space.
With wordwrap().
genzoeri
I am use this script to read file text..
fopen(""); and fgets("");
hope this help you..
Related topics
simple php problem, please help...
MySQL and Php
[php/SQL] Help needed
Help needed about this contact CGI file
how to compress a file using php ?
php..free account help
Help needed!!! urgently
Where is the php.ini file?
A Question about the PHP.INI file.
Big Help needed .
Help Needed with phpBB overall_header.tpl
Help needed
Help needed with images in php include files
consistently get different script errors when logged in
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.