// Find all $content[foo]
preg_match_all('/\$(content|GLOBALS)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches);
+ // Replace " with {QUOTE}
+ $code = str_replace('"', '{QUOTE}', $code);
+
// Replace all
foreach ($matches[0] as $key=>$match) {
// Replace it
- $code = str_replace($match, "\" . \$content['" . $matches[3][$key] . "'] . \"", $code);
+ if (substr($match, 0, 8) == '$GLOBALS') {
+ // $GLOBALS
+ $code = str_replace($match, "\" . \$GLOBALS['" . $matches[4][$key] . "'] . \"", $code);
+ } elseif (substr($match, 0, 8) == '$content') {
+ // $content
+ $code = str_replace($match, "\" . \$content['" . $matches[4][$key] . "'] . \"", $code);
+ }
} // END - foreach
// Return it