I have found out how to replace whats in every table....
But i want it a little better, like Just a common table, one thats used often in the page.. Could anyone try beef up this script i made for me?
$str = "<table width='100%'><tr><td width='50%'>HELLO</td><td width='50%'>HELLO</td></tr></table><br>
<table width='100%'><tr><td width='100%'>HELLO</td></tr></table><br>
<table width='100%'><tr><td width='100%'>HELLO</td></tr></table><br>";
echo("<b>BEFORE: </b><br>".$str."<br><BR>");
$str = @ereg_replace("<td([^>]+)>","\\0{td}",$str);
$str = @ereg_replace("<([^>]+)td>","{td}\\0",$str);
$str_arr = explode("{td}",$str);
$i = "1"; $c = count($str_arr);
foreach($str_arr as $item)
{
if($i % 2 == 0)
{
$l = $i - "1";
$str = str_replace($str_arr[$l],"",$str);
}
$i++;
}
$str = @str_replace("{td}{td}","YO NEW CONTENT",$str);
echo("<b>AFTER: </b><br>".$str);
Any help Greatly Appreciated, And thanks for helping so far 😉
PS: I only used:
ereg_replace();
str_replace();
explode();
foreach();
count();
and only used echo() to test it 😛, and i did this in 35 minutes 😃
The script isn't ouputted properly on the forum... in the first 2 ereg_Replace() functions there is "\0", replace this with "\0" to get it to work....