Variable MyCode?
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Variable MyCode?
For ease with regular expressions you may wish to use different tags for setting and getting the variable.

Lazy example code (PHP 5.3 only cause I'm extra lazy):

PHP Code:
$postvars = array();
$post['message'] = preg_replace_callback('~\[set\=([a-z0-9]+)\](.*?)\[/set\]~si', function($m) use(&$postvars) {
	$postvars[strtolower($m[1])] = $m[2];
}, $post['message']);
$post['message'] = preg_replace('~\[variable=([a-z0-9]+)\]~ie', '$postvars[strtolower(\'$1\')]', $post['message']);


My Blog
(This post was last modified: 01-16-2012 10:23 AM by ZiNgA BuRgA.)
01-16-2012 10:21 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Variable MyCode? - PK8 - 01-16-2012, 12:07 AM
RE: Variable MyCode? - ZiNgA BuRgA - 01-16-2012 10:21 AM

 Standard Tools
Forum Jump: