Help converting PHP eregi to preg_match

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2010-04-19T04:33:20Z Indexed on 2010/04/19 4:43 UTC
Read the original article Hit count: 363

Filed under:
|

Hi all,

I am wondering if someone could please help me convert a piece of PHP code that is now deprecated.

Here is the single line I am trying to convert:

if(eregi(trim ($request_url_handler[$x]),$this->sys_request_url) && $this->id_found == 0){

It is part of a function that return the configuration settings for a website. Below is the whole function.

// GET CORRECT CONFIG FROM DATABASE
function get_config($db)
{
    global $tbl_prefix;
    $db->query("SELECT cid,urls FROM ".$tbl_prefix."sys_config ORDER BY cid");

    while($db->next_record()){
        $request_url_handler = explode("\n",$db->f("urls"));
        if(empty($request_url_handler[0])) {
            $request_url_handler[0] = "@";
            $this->id_found = 2;
        }

        for($x=0; $x<count($request_url_handler); $x++) {
            if(empty($request_url_handler[$x])) {
                $request_url_handler[$x] = "@";
            }
            if(eregi(trim($request_url_handler[$x]),$this->sys_request_url) && $this->id_found == 0) {
                $this->set_config($db,$db->f("cid"));
                $this->id_found = 1;
            }
        }

        if($this->id_found == 1) {
            return($this->sys_config_vars);
        }
    }

    $this->set_config($db,"");
    return($this->sys_config_vars);
}

Any help would be great ly appreciated. I only found the the eregi function was deprecated since I updated XAMPP to 1.7.3.

© Stack Overflow or respective owner

Related posts about ereg

Related posts about preg-match