Geat
08-20-2003, 10:25 AM
Consider the line:
$preview_code = ereg_replace ("\@\@([^\@]*)\@\@", $myarray["\\1"], $preview_code);
Okay, I know the parenthesised section ([^\@]*) is going to be a valid array index for my predefined associative array. So, I want the replacement text to be that array's element. E.g, if the string is:
My name is @@name1@@, hello!
And the array is:
$myarray["name1"] = "George";
Then the replace code should return
My name is George, hello!
But doesn't.
Does anyone know how to force the "\\1" to be evaluated BEFORE it is used to reference the array item?
Help!
$preview_code = ereg_replace ("\@\@([^\@]*)\@\@", $myarray["\\1"], $preview_code);
Okay, I know the parenthesised section ([^\@]*) is going to be a valid array index for my predefined associative array. So, I want the replacement text to be that array's element. E.g, if the string is:
My name is @@name1@@, hello!
And the array is:
$myarray["name1"] = "George";
Then the replace code should return
My name is George, hello!
But doesn't.
Does anyone know how to force the "\\1" to be evaluated BEFORE it is used to reference the array item?
Help!