|
-
Jun 2nd, 2005, 11:09 AM
#1
Re: return a single line from a text doc
Have a look at the file() function - it should help you 
Cheers,
RyanJ
-
Jun 2nd, 2005, 11:42 AM
#2
Thread Starter
Hyperactive Member
Re: return a single line from a text doc
ok i get what that function does but i dont get how to make it display only one line and that line being $line. how do i do this?
If there is only one perfect person in the universe, does that make them imperfect?
-
Jun 2nd, 2005, 12:00 PM
#3
Re: return a single line from a text doc
 Originally Posted by dandono
ok i get what that function does but i dont get how to make it display only one line and that line being $line. how do i do this?
Because the function returns the array, just pass the $line as the index to get the required line 
Cheers,
RyanJ
-
Jun 2nd, 2005, 02:44 PM
#4
Thread Starter
Hyperactive Member
Re: return a single line from a text doc
i think that this is not the best way to do this but it is the only way i can think. now somebody is going to come up with a code a houndred times better than mine in like five minuets.
this is my code. i will set it to open a local text file in a bit.
PHP Code:
<?php
// Get a file into an array. In this example we'll go through HTTP to get
// the HTML source of a URL.
$lines = file('http://www.php.net/');
$no = $_GET['line'];
// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
if ($line_num == $no)
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
}
// Another example, let's get a web page into a string. See also file_get_contents().
$html = implode('', file('http://www.example.com/'));
?>
thanks for the help
If there is only one perfect person in the universe, does that make them imperfect?
-
Jun 2nd, 2005, 02:49 PM
#5
Thread Starter
Hyperactive Member
Re: return a single line from a text doc
how do you get that code to view a text doc on the server mechine like the path D:/blah.txt? is it just with fread?
If there is only one perfect person in the universe, does that make them imperfect?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|