Any idea why this won't work. I'm trying to replace every second <TR> with <tr class=\"Body2\">.
function update_content_CHL(&$CHL_content) { // use this to modify the HTML tags etc
$CHL_content = str_replace('<TABLE>','<TABLE Width="100%">',$CHL_content);
$CHL_content = str_replace(' in Rankings','',$CHL_content);
$CHL_content = str_replace('Rank','R',$CHL_content);
$CHL_content = str_replace('(','<br>(',$CHL_content);
$CHL_content = str_replace(' Week','',$CHL_content);
//$CHL_content = str_replace('<TR>','<TR class="Body2">',$CHL_content);
$instance = 1;
for ($i=0; $i<=strlen($CHL_content); $i++) {
if (substr($CHL_content, $i, 4) == "<TR>") {
if ($instance % 2 == 0) {
substr_replace($CHL_content, "<tr class=\"Body2\">", $i, 4);
}
$instance++;
}
}
}