line breaks in between fetched file names


Posted on 16th Feb 2014 07:03 pm by admin

Hi,

I have this code:
Code: <?php
Did you know?Explore Trending and Topic pages for more stories like this.
if($dir = opendir('files')){
while (($file = readdir($dir) )!== false){
if ($file !='.' && $file !='..'){
echo '<a href="' . $file . '">' . $file . '</a>';"n";

}
}
closedir($dir);
}
?>
but when it outputs the files from the files folder, it lists them one after another with no spaces etc. How can I make it list one file per line?

e.g.
file_1.doc
file_2.png
file_3.exe

Thanks
No comments posted yet

Your Answer:

Login to answer
176 Like 40 Dislike
Previous forums Next forums
Other forums

How to show next and prev records
Hi all,

Sorry if this is simple, i'm very new to php, well, any programming language actually

Procedural to OOP
John Kleijn said that to avoid writing "crappy code", we should learn OOP and common OO pr

getting a website's source code as a variable? How?
Hey guys, is there any way for me to get the source code of a website as a variable for me to work w

have trouble in a if condition
The if below is working ok, it check when indexes, name, zipcode and state are empty.
Code: &

mysq_num_rows
Hi,

I want to use:

Code: if(mysql_num_rows($ergebnis2)==2)
how can the value 2, be

GET vs SUBMIT Button to show sections on one index.php page?
Just curious if one of these ways is better (i.e. more efficient) than the other.

I have a

Line break?
Hi, I'm new to the forum and new to php. I'm not sure if I'm using the correct terminology so here i

login page does not execute a else statement
I've created a login page using sessions.
When an incorrect user name or password is entered then

How to ask a regex question?
Hi, I thought I'd share some of my insight after seeing too many bad questions that either get ignor

how to make database item unique
Hey guys,

is it possible to do this:

I have the database item $title being pulled for

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash