Hello.
Objective: To remove portions of text found by 'preg_match' by substituting a variable in its place; modify each match found based upon some condition; preg_replace() back into those spots (variables) then parse using eval().
Is this possible?
I tried it but can't get the vars to parse.
Here is a brief overview of what I did:
1) preg_match_all('...',$text,$match)
2)
if ($match[$x][$y] == $match[$x][0])
{
$align[$y] = $match[$x][0];
$search[$y] = "#".preg_quote($align[$y], '#')."#";
$replace[$y] = "\$var[" . $y . "]";
$var[0] = $align[0];
$var[1] = $align[1];
}
$text = preg_replace($search, $replace, $text);
AFTER the substitution of the vars into the text, the value of $text becomes:
'Here is the basic properties as described by $var[0] and as the parts are built with the color $var[1], the new description becomes complete.'
...which is what I want.
In reality, I want to replace HTML tags, etc. as appropriate within each of these vars, $var[$y].
3) eventually this will lead to finding something specific within each match found in step 1, modifying it, redefining the $var[], then resubstitute the new value back into $text.
I hadn't gotten to step 3, yet because I haven't gotten pass step 2 testing where all I wanted to do was resubstitute the original text segments back into their respective areas of the original text by...
eval('$text1 = $text;');
whereby each $var[$y] is parsed back into their respective places within the $text and then print out the result either as a revised version of the var, $text, or to rename the revised version to $text1.
Again, is this possible? If so, how to get the $var[$y] to become parsed?
The result in the eval() statement as shown above just assigns $text1 the same value as $text above with the vars named as shown above as (literally):
'Here is the basic properties as described by $var[0] and as the parts are built with the color $var[1], the new description becomes complete.'
...without parsing.
Is it because the 'eval()' syntax is not correct? What is the correct syntax, or what is needed if it's possible to do?
Thanks in advance.