## Use of preg_match instead ereg

Hi,

I have the following function for listing files in a directory with given extenstion/file type.

PHP Code:
``` function file_list(\$d, \$x){  foreach(array_diff(scandir(\$d), array('.', '..')) as \$f) if (is_file(\$d . '/' . \$f) && ((\$x) ? ereg(\$x . '\$' , \$f) : 1)) \$l[] = \$f; return \$l; }  ```
Earlier it worked fine however now I see an error in error logs - given below.

Code:
`[15-Nov-2013 11:35:00 America/New_York] PHP Deprecated:  Function ereg() is deprecated in /home/****/public_html/****/API/***.php on line 21`
Can someone please let me know a solution for this, I tried with preg_match but it didnt help me.

It seems I have put a different regex which I do not understand.