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?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.