STR_REPLACE with PHP and RTF
Posted on 2003-03-06
Ok, so I have a program that generates values that will be used to populate a RTF template. For example, a script creates the values $sub_total, $tax, and $total. In the RTF template that I am using, I have the placeholders setup as <<SUB>>, <<TAX>> and <<TOTAL>>. I want a way to go through the entire RTF file and replace the PHs with the correct values. I saw in another question the following answer:
$file_contents = join('',file('test.rtf'));
$output = str_replace('<<SUB>>',$sub_total,$file_contents);
$output = str_replace('<<TAX>>',$tax,$file_contents);
$output = str_replace('<<TOTAL>>',$total,$file_contents);
But when I use that, it only replaces one PH and the others just remain. It seems to only replace the last var (<<TOTAL>>). Can someone help?