you dont even need a php script, if you point your web browser to a dir on an apache server what you showed is what you get if you dont have an index page or a configuration to exclude directory listings.
if you really want a php script there are several in the user notes under glob() and opendir and scandir