Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP File Handling with PHP Basic File Handling Review Basic File Handling

Vedran Linić
Vedran Linić
10,050 Points

Why is this not correct?

Why is this question not correct?

Complete the code for reading files from the "img" directory into an array. $images = file('img');

1 Answer

David Evans
David Evans
10,490 Points

Hi Vedran,

The question is asking you to read all files from a specified directory. In this case the 'img' directory.

PHP's file() function reads an entire file into an array, as such it isn't meant to be used to read a directory ( a folder ).

The quiz is looking for you to use PHP's scandir() function.

You can read about it here: http://php.net/manual/en/function.scandir.php

 $images = scandir('img');
Vedran Linić
Vedran Linić
10,050 Points

Thank you for the explanation.