Broke Code: ereg deprecated could anyone help?

Hi Friends here at CI. I have an older program that I was working on that used php 4.1. Yes its outdated I know. lol I upgraded the program to php 5.3 but im now having an issue with this code.

I have read that ereg has now been deprecated in php, but does anyone now the replacement? or at a glance any one know what could fix this now broken code?

$path = $this->config->item('icons').$this->session->userdata('user_id');
                    $dir_handle = @opendir($path) or die("Unable to open folder");
                    while (false !== ($file = readdir($dir_handle))) {
                    if(ereg("(.*)\.(jpg|bmp|jpeg|png|gif)", $file)){
                    echo "<a href='/dashboard/selecticon/$file'><img src='$path/$file' alt='$file' width='100' height='100'></a> ";

Thanks a million in advance.


As the PHP manual suggests, replace ereg() by preg_match()

if(preg_match("/^(.*)\.(jpg|bmp|jpeg|png|gif)$/i", $file)){

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.