I didn't want to overcomplicate the question, but here it goes. I'm trying to pull values from a string (eventually will be a file) that contains delimiters within [[]]. The index from an array I'm pulling is exactly the name of [[]].
So in this case, [[THIS]] can be called with $i_ar['NEW:THIS][0] and return a value. I'm replacing [[ with $i_ar['NEW: and ]] with ][0]. So instead of displaying the string, I want the value of the array called. Hope this clarifies it a bit and thanks for the help!!
$template = 'Replace [[THIS]] and [[THISTOO]]';
$parser = xml_parser_create ();
$ipinfo = implode ("", file("xml.txt"));
xml_parse_into_struct($parser, $ipinfo, $d_ar, $i_ar);
preg_match_all('/\[\[.+?\]\]/', $template, $matches);
$begin = '$i_ar['NEW:';
$end = '\'][0]';
foreach ($matches[0] as $line) {
$newline = str_replace('[[', '', $line);
$newline = str_replace(']]', '', $newline);
echo "$begin$newline$end";
}