+1 to this suggestion.  Given there is some question about whether this returns <head> or not, maybe it would be safer (and more succinct) to match/replace:

    array( '/^.*?<body>/si', '/<\/body><\/html>$/si')