# Converting to array

**URL:** https://forum.kirupa.com/t/converting-to-array/225661
**Category:** Uncategorized
**Created:** [May 14, 2007, 7:09pm UTC](https://forum.kirupa.com/t/converting-to-array/225661 "2007-05-14T19:09:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rapier\_gv](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@rapier\_gv](https://forum.kirupa.com/u/rapier_gv)
#### Post date: [May 14, 2007, 7:09pm UTC](https://forum.kirupa.com/t/converting-to-array/225661/1 "2007-05-14T19:09:39Z")

</div>

hi all, i’m not much of a php guru, so here’s my question  
i have created a very basic script which shows the content of a certain directory like so

```php
if ($myDir = opendir('.')) {
  
    while (false !== ($file = readdir($myDir))) {
        if ($file != "." && $file != "..") {
            echo "$file<br />
";
            
        }
    }
    closedir($myDir);
}

```

and now the silly and probably noobish question: how can i convert the list of contents from the directory to an array?

thanks
