Forum Moderators: coopster
$original = "This is the [replace] statement";$new = ereg_replace('\\[(.*)\\]', '\\1', $original);
What I'm essentially looking to do is replace the contents of the brackets with the value of a variable of the same name.
Example:
$replacetext = "desired text";$original = "This is the [replacetext] statement";
$new = ereg_replace('\\[(.*)\\]', '$\\1', $original);
//$new = "This is the desired text statement";
Any suggestions?
$new = preg_replace('/\[(.*)\]/e', '$${1}', $original);
$new = preg_replace('/\[([a-z]+)\]/e', '$$1', $original);