GetDotted Domains

Viewing Thread:
"PHP help required..."

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Fri 19/03/04 at 17:14
Regular
"Digging!"
Posts: 1,560
Hay all,
I have a nice little PHP script which saves me a lot of fiddling on my site which is as follows:


// Define the full path to your folder from root
$path = "/home/freehost/t35.com/s/t/stevesmiscellany/WEBSITES/";

// Open the folder
$dir_handle = @opendir($path) or die("Unable to open $path");

// Loop through the files
while ($file = readdir($dir_handle)) {

if($file == "." || $file == ".." || $file == "sitemap.php" )

continue;
echo "$file";

}

// Close
closedir($dir_handle);

?>

The problem is that it displays all the files as a continuouse list one after each other, bu I want it to put "Enter"s inbetewn each file as per

 

in HTML. How would I change the script to do this?

Many Thanks
S.A.
Sun 21/03/04 at 12:36
Regular
"Digging!"
Posts: 1,560
Turbonutter wrote:
> Take a look at this. [URL]
> http://www.sine-wave.net/view-source.php?file=./list.php [/URL].
>
> These tags are really badly thought out.


As you may have guessed I'm still learning PHP and this is my first proper peice of code. I really don't want to write another one just add a couple of lines that will remove the extensions.
Sun 21/03/04 at 01:25
Regular
"whoneedsatagline?"
Posts: 194
Or try this sort of logic which works out the suffix then removes it:


$file1 = "xyz.php";
$suffix = strstr($file1, '.');
$file2 = basename($file1, $suffix);
echo "$file1
$suffix
$file2
";

$file1 = "abc.html";
$suffix = strstr($file1, '.');
$file2 = basename($file1, $suffix);
echo "$file1
$suffix
$file2
";

?>
Sun 21/03/04 at 01:14
Regular
"Eff, you see, kay?"
Posts: 14,156
Take a look at this. [URL] http://www.sine-wave.net/view-source.php?file=./list.php [/URL].

These tags are really badly thought out.
Sat 20/03/04 at 21:21
Regular
"Digging!"
Posts: 1,560
Still cant get he damn extensions from apprearing.
Fri 19/03/04 at 21:51
Regular
Posts: 10,437
You could try changing $file to a different variable, then use a substitution to get rid of the leading extension.

I'm not sure if it's the same as Perl, but something like this would do it:

$new=$file;
$new=~s/[.]+$//;

You'll probably need a very similar script, I'm sure somone on this forum will know.
Fri 19/03/04 at 19:57
Regular
"Digging!"
Posts: 1,560
Rickoss wrote:
> I'm don't really know much about PHP, but couldn't you just add > />
> not understanding exactly what you want to do... :-\

Oh, and cheers for your help, it pushed me in the right dirrection.
Fri 19/03/04 at 19:56
Regular
"Digging!"
Posts: 1,560
But I am still unsure how to stop the file extensions appearing (eg I want a like saying Banners, rather than Banners.php)

S.A.
Fri 19/03/04 at 19:48
Regular
"Digging!"
Posts: 1,560
I feel very stupid now, I just needed to add

s within the current echo, e.g. echo "

$file

";
Fri 19/03/04 at 19:13
Regular
Posts: 10,437
I'm don't really know much about PHP, but couldn't you just add

to the end of the echo? Of course, it's probably me just not understanding exactly what you want to do... :-\
Fri 19/03/04 at 17:23
Regular
"Digging!"
Posts: 1,560
Miserableman wrote:
> I'm not sure how that script works in its current form, but adding
> echo('

 

'); below your current echo
> function may work.

Alas, that does not work. I had tried that and it just adds an enter to the end of th list.

I'll post the URL to show you what I mean by a continousise list:
http://stevesmiscellany.t35.com/sitemap.php

S.A.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

I am delighted.
Brilliant! As usual the careful and intuitive production that Freeola puts into everything it sets out to do. I am delighted.
LOVE it....
You have made it so easy to build & host a website!!!
Gemma

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.