convert to preg_replace

I am new to PHP, ereg_replace is deprecated so need to convert ereg_replace to preg_replace, I can’t figure out how to put “delimiters and escape character” on $TEST_FILE below, can someone help me on this.

function KernelBase(){

        $i=0;
        $TEST_FILE="fdKernel/Init.php";
        $TEST=$TEST_FILE;
            while(!file_exists($TEST))
            {
            $TEST="../".$TEST;
            if($i>15)
            break;
            $i++;
            }
            return trim(ereg_replace($TEST_FILE,NULL,$TEST))."fdKernel/";   
        }

ereg_replace ( string $pattern , string $replacement , string $string )

preg_replace ( string $pattern, string $replacement, string $string )

See the commonality?

Sponsor our Newsletter | Privacy Policy | Terms of Service