Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 09-01-2015, 06:24 PM   #1
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
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);
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-01-2015, 06:37 PM   #2
sarettah
I'll make you famous
 
Industry Role:
Join Date: Oct 2002
Posts: 13,955
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.

.
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-01-2015, 06:48 PM   #3
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by sarettah View Post
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
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-01-2015, 07:00 PM   #4
sarettah
I'll make you famous
 
Industry Role:
Join Date: Oct 2002
Posts: 13,955
Quote:
Originally Posted by acctman View Post
thanks that worked
Cool.

.
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
$value, deprecated, preg_replace_callback, language, $value;, fopenlanguages, $langs[$key][l_file], r, $value[l_code], $langs, $key, diecannot, lang, break;, .$langs[$key][l_file];, explode=, $s, 2;, list$key, $value, continue;, preg_replace//sue, @constant1, fclose$f;, $def[$key], $s0, foreach, file, feof$f



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.