Code: Select all
if(preg_match_all("/(\{if(.+?)\}.+?\{\/if\})/ism", $src, $matches))I'd think it was a PHP bug in my version, but I know how php ignorant I am. I've tried many for() and foreach() loops, many print_r()'s and many hours with a headache.
What is the correct way to loop through $matches and get the value of (.+?) in the regex, for each set of matches that preg_match_all() finds?
... I probably just need sleep.
Here's my current coding after hours of deleting, editing, & trying again.
Code: Select all
private function _replace_if($src)
{
if(preg_match_all("/(\{if(.+?)\}.+?\{\/if\})/ism", $src, $matches))
{
// echo '<pre>';
print_r($matches);
// echo '</pre>';
for($i = 0; $i < count($matches); $i++)
{
$statement = str_replace(array('(', ')'), '', $matches[2][$i]);
if(eval("return $statement;"))
{
echo 'true';
//$src = str_replace('{if(' . $statement . '}
} else
{
echo 'false';
}
}
}
}