logo CodeStepByStep logo

scandir_vs_glob1

Language/Type: PHP basics file io
Author: Melissa Hovik (on 2018/11/22)

Suppose a directory trivia-service has the following structure:

trivia-service/
    trivia.js
    trivia.php
    trivia/
        astronomy/
            astronomy1.txt
        internet/
            internet1.txt
            internet2.txt
        pokemon/
            pokemon1.txt
            pokemon2.txt

What would each of the following statements return if written in trivia.php, run from the trivia-service/ directory? Use [] notation for any arrays and put strings in "".

scandir("trivia")
scandir("trivia/astronomy")
glob("trivia")
glob("trivia*")
glob("*/.txt")
glob("*/*/*2.txt")

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.