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.

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

Please do tell little briefly....

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.