In a simple template parser anywhere $00, $11, etc. appears in the HTML it is being removed. I don’t see what’s in my pattern that is causing $10 to be stripped from the replacement.
What is strange is I’ve commented out nearly all of my code except the main preg_replace function that handles the tag. Seemingly there is no connection, but nearly everything else has been removed.
Function (not showing what’s commented out):
public function output() {
$output = file_get_contents($this->file);
foreach ($this->values as $key => $value) {
$dynamic = preg_quote($key);
$pattern = '%\[@'.$dynamic.'.*?\]%';
$output = preg_replace($pattern, $value, $output);
if ($key == 'objective') {
$objective = $value;
}
}
}
HTML Excerpt:
[if @objective]<div id="objective">[@objective]</div>[/if]
Original value of ‘objective’ (ie, $value):
Obtain a position at XYZ Company where $words $100 !100 maximize my management skills, quality assurance, program development, and training experience.
New value of ‘objective’:
Obtain a position at XYZ Company where $words 0 !100 maximize my management skills, quality assurance, program development, and training experience.
(Follow-up to comment on the question.)
$xx(wherexis a digit) is used for backreferences in the replacement string ofpreg_replace. If you want the replacement string to contain$xx, you have to escape it:This will replace
$xxby\$xxin$value.