preg_match to get mp3 and mp4 filenames in file extension order then in filename order from an external webpage?
<p>I am new to PHP. I have tried many times and cannot come up with the search pattern to get all the mp3 and mp4 files name from an external HTML.  The list of files is in file extension order than the file name order.  I would appreciate if any help.</p>

<pre><code>$file = 'http://70.123.0.111//lrs/35/';
$searchfor = '&lt;a herf';
echo $searchfor;

// the following line prevents the browser from parsing this as HTML.
header('Content-Type: text/plain');

// get the file contents, assuming the file to be readable (and exist)
$contents = file_get_contents($file);

// escape special characters in the query
$pattern = preg_quote($searchfor, '/');

// finalise the regular expression, matching the whole line
$pattern = "/^.*$pattern.*\$/";

// search, and store all matching occurences in $matches
if(preg_match_all($pattern, $contents, $matches)){
   echo "Found matches:\n";
   echo implode("\n", $matches[0]);
}
else{
   echo "No matches found";
}   
</code></pre>

<h2>HTML codes</h2>

<p>70.123.0.111 - /lrs/35/<H1>70.123.0.111 - /lrs/35/</H1><hr></p>

<p><pre><A HREF="/lrs/">[To Parent Directory]</A><br><br> 7/17/2008  9:02 PM    178899264 <A HREF="/lrs/35/0102.mp3">0102.mp3</A><br> 7/18/2008 12:30 AM    558244970 <A HREF="/lrs/35/0102.mp4">0102.mp4</A><br> 7/17/2008  9:38 PM    186016896 <A HREF="/lrs/35/0304.mp3">0304.mp3</A><br> 7/18/2008  1:44 AM    580476123 <A HREF="/lrs/35/0304.mp4">0304.mp4</A><br> 7/17/2008 10:13 PM    186478272 <A HREF="/lrs/35/0506.mp3">0506.mp3</A><br> 7/18/2008  2:59 AM    581455848 <A HREF="/lrs/35/0506.mp4">0506.mp4</A><br> 7/17/2008 10:44 PM    166862592 <A HREF="/lrs/35/0708.mp3">0708.mp3</A><br> 7/18/2008  4:02 AM    520139478 <A HREF="/lrs/35/0708.mp4">0708.mp4</A><br> 7/17/2008 11:19 PM    188616096 <A HREF="/lrs/35/0910.mp3">0910.mp3</A><br> 7/18/2008  5:16 AM    590308801 <A HREF="/lrs/35/0910.mp4">0910.mp4</A><br>12/11/2008  8:15 PM       688347 <A HREF="/lrs/35/qfm_hetu_vidya.pdf">qfm_hetu_vidya.pdf</A><br>12/11/2008  2:08 PM       421978 <A HREF="/lrs/35/ym_notes.pdf">ym_notes.pdf</A><br></pre><hr></p>
