# PHP readdir() question?

**URL:** https://forum.kirupa.com/t/php-readdir-question/192833
**Category:** Uncategorized
**Created:** [July 1, 2006, 6:55pm UTC](https://forum.kirupa.com/t/php-readdir-question/192833 "2006-07-01T18:55:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tanel96](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@tanel96](https://forum.kirupa.com/u/tanel96)
#### Post date: [July 1, 2006, 6:55pm UTC](https://forum.kirupa.com/t/php-readdir-question/192833/1 "2006-07-01T18:55:51Z")

</div>

```php

<?php
if ($handle = opendir('/path/to/files')) {
echo "Directory handle: $handle
";
echo "Files:
";
while (false !== ($file = readdir($handle))) {
echo "$file
";
}
closedir($handle);
}
?> 

```

Now, how do i order the files alphabetically ? For readdir() PHP manual says:

> “The filenames are returned in the order in which they are stored by the filesystem.”  
> :look:
