I am trying to use preg_replace function to parse this table in a Html page :
Tuition. $13,140 $13,167 $13,167
Books $996 $1,176 $1,176
Because of table tags I got “Unknown modifier ‘t‘ ” error and I changed ‘/ /‘ with ‘~ ~‘.
Still I have problem, the function is not changing the text. I think the problem with ‘$‘ dollars sign in the text, how can I skip it? I tried to do but I couldn’t.
Here is my code :
$price = $html->find('div[id=divctl00_cphCollegeNavBody_ucInstitutionMain_ctl00] table[class=tabular]');
$price1=$price[0];
$show=$price1;
$ch="~".$show->children(1)->children(0)->children(1)."~";
$show=preg_replace($ch,' ',$show, 1);
Thanks
try this :
$show=preg_replace(str_replace('$','\$',$ch),' ',$show, 1);If you can’t use preg_quote and have multiple escape ( in this case $ is your problem), you could put your special character in an array and filter from it.