The code below is not a functioning method it's just written to help you understand what I'm trying to do.
// $i = occurrence to replace
// $r = content to replace
private function inject($i, $r) {
// regex matches anything in the format {value|:value}
$output = preg_replace('/\{(.*?)\|\:(.*?)\}/', '$r', $this->source);
$output[$i]
}
How do I find the $i occurrence in $output; and replace it with $r;?
Note: All I want to do is use $i (which is a number) to find the occurrence of that nmber in a preg_replace; For exmaple: I might want to replace the second occurrence of the preg_replace pattern with the variable $r