Log in

View Full Version : Directory hyperlinks



phrozen1
05-22-2013, 04:16 PM
Can anyone help me out with this?

I have a website where I post results from races in .html or .pdf.

Every time I post the results in a directory, I have to manually create a hyperlink

I want a php script that will scan the directory and then create a list of hyperlinks ordered by the date of the file. I also would also like the links to not have the .pdf or .html extension on the end. I also do not want the underscore in the hyperlink but a space instead.

Thanks for any help

traq
05-22-2013, 07:54 PM
Every time I post the results in a directory, I have to manually create a hyperlink
I want a php script that will scan the directory and then create a list of hyperlinks ordered by the date of the file.

You should look at the glob() (http://php.net/glob) function. How much experience do you have with PHP? Do you know the basics? Do you know how to write hyperlinks with PHP, for example?


I also would also like the links to not have the .pdf or .html extension on the end. I also do not want the underscore in the hyperlink but a space instead.

If you're talking about the link text, that's not a problem. you can use something like str_replace() (http://php.net/str_replace) for making such changes.

phrozen1
05-23-2013, 01:24 AM
I have a basic understanding of PHP, but would consider myself a beginner. Would this require a lot of coding?

djr33
05-23-2013, 01:30 AM
This shouldn't be too hard for you to figure out. You'll need to take it step by step and look up tutorials (or just functions) for the individual steps. For example, the last step will be how to choose to display the text of the link itself, which is unrelated to the rest of the process. Breaking it down like that will make it seem easier (and is necessary anyway).

A great reference, if you're not already familiar with it, is php.net for the extensive information about all of the functions-- you can look up glob() and str_replace() there to start. There are also short code examples with these functions, so you can start with those and adjust them for your purposes.

If you try this and have more specific questions feel free to ask here, but at the moment it's a little unclear what to suggest-- try something and let us know how it goes. Starting with glob() is fine. There's also another route of using fopen(), fread() and fclose(), all with examples on php.net.