GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP preg_replace_callback help needed (https://gfy.com/showthread.php?t=1173200)

acctman 09-01-2015 06:24 PM

PHP preg_replace_callback help needed
 
trying to avoid going on stackoverflow don't want to deal with the Q&A ego police that mod that site. Any i'm getting this error Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in any assistance greatly appreciated

Code:

//load current language
        foreach ($langs as $key => $value) if ($value['l_code'] == lang) break;
        $f = fopen('languages/'.$langs[$key]['l_file'],'r') or die('Cannot open language file '.$langs[$key]['l_file']);
        while (!feof($f)) {
                $s = chop(fgets($f,4096));
                if ($s{0} == '#') continue;
                list($key,$value) = explode('=',$s,2);
                $value = preg_replace('/<%(.*)%>/sUe', '@constant("\\1")', $value);
                $def[$key] = $value;
                }
        fclose($f);


sarettah 09-01-2015 06:37 PM

I don't deal with preg_replace that often but after spending a couple of minutes looking at preg_replace_callbak I am thinking that something like this will work:

$value = preg_replace_callback('/<%(.*)%>/sU', function(){ return @constant("\\1"); }, $value);

Worst that can happen is it won't ;p

edited in: also remove the e modifier I think. I forgot to do that originally.

.

acctman 09-01-2015 06:48 PM

Quote:

Originally Posted by sarettah (Post 20567647)
I don't deal with preg_replace that often but after spending a couple of minutes looking at preg_replace_callbak I am thinking that something like this will work:

$value = preg_replace_callback('/<%(.*)%>/sU', function(){ return @constant("\\1"); }, $value);

Worst that can happen is it won't ;p

edited in: also remove the e modifier I think. I forgot to do that originally.

.

thanks that worked :)

sarettah 09-01-2015 07:00 PM

Quote:

Originally Posted by acctman (Post 20567658)
thanks that worked :)

Cool.

.


All times are GMT -7. The time now is 03:12 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc