Link to home
Start Free TrialLog in
Avatar of level9wizard
level9wizardFlag for Canada

asked on

PHP & Regex : Replace entire <head>

I'm storing an entire html page in $html. I need to replace everything from <head> to </head> with my own $head (so either the stuff inside is replaced, or the stuff inside and the tags - whichever makes more sense). How can I do this?
Avatar of shobinsun
shobinsun
Flag of India image

$html = preg_replace("|<head>(.*)</head>|m",$newhead,$html);
ASKER CERTIFIED SOLUTION
Avatar of hampus_b
hampus_b
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial