0

hi,
In my application ,i am able to upload a file in my server...now i want to display the first three lines of the uploaded file.please do tell me how to do tat.

2
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by queenc
0

hi,
In my application ,i am able to upload a file in my server...now i want to display the first three lines of the uploaded file.please do tell me how to do tat.

Take a look at this on PHP.NET, should be exactly what you want . . .

http://uk2.php.net/manual/en/function.file.php

Look half way down the page at the example.

Green2Go

0

thanks tat was useful.i used tat code this way......

<?php
$lines = file('http://www.website.com/simple.txt');
foreach ($lines as $line_num => $line) {
if ($line_num >=0 && $line_num <= 3)
{
    print "<a href='http://www.website.com/simple.txt'>". htmlspecialchars($line) . "<br />\n</a>";
}
}
?>

Now please tell me how to use word wrap in this,the above code will display the first three lines in a file.

0

Have a look a this:

http://en.wikibooks.org/wiki/Programming:PHP/Files

There is a section 3/4 down the page that explains line endings. Word wrap will simply shuffle content to the next line if the content cannot be displayed within the current lines availible line length, this will be performed until EOF.

Have a look how the Windows note pad (providing your using windows!) functions with word wrap on and off.

One other note is that if the HTML is going to be parsed before display you will not need to wrap the HTML code but only the displayed output.

Green2Go

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.