I have a folder which contains several html files: 1.html
, 2.html
, 3.html
, etc., etc. in sequential order.
I would like for PHP to randomly load in these files into a PHP webpage that I have. How can I go about doing this?
Also -- is PHP the most efficient way to do this? Would jQuery be better?
jquery could do it, but you'd have to send a list of the available files to the client beforehand, so it has a list to choose from. This would be required if you can't guaranteed there'll never be "holes" in the files, e.g.
1,2,4,5
(hey, where's 3?).PHP can deal with the raw filesystem, and can always get the list of files, e.g.
This will handle any
.html
file, regardless of holes in the numbering sequence, or even if they're numbered at all.