Question: I have a url, `http://www.mysite.com/images` and the `images` directory allows Directory Listings. How can I get the files in that directory with PHP?

Answer: 
I know this question is very old, but just to get me into the swing of using this forum I thought I'd add my view. I found the following happened (referring to the original answer to use regex.

My html turned out to be formatted like this:

```
<td>
<a href="bricks.php">bricks.php</a>
</td>

```

So I ended up using this:

```
$count = preg_match_all('/<a href=\"([^\"?\/]+)">[^<]*<\/a>/i', $html, $files);

```

I wanted to use the following (which tested ok in the online generator testers, but it failed to find a match in the php code):

```
$count = preg_match_all('/<td>(?:[\w\n\f])<a href="([^"]+)">[^<]*<\/a>(?:[\w\n\f])<\/td>/i', $html, $files);

```
You can use regex to take urls from listing. (No you can't use DOMDOCUMENT as it's not a valid HTML)