You can try this code, it seems like it worked for me:
// strpos() >>is<< case sensitive
// add 5 to not count the <head>
$left = strpos($content,"<head>") + 5;
// minuse $left for length
$right = strpos($content,"</head>") - $left;
$new_output = substr($content,$left,$right);
Hope this can get you started.
-Josh