定位端头标签以在其前面插入样式表

I'm trying to add some things into the head section of a page the problem is I use a cms (vBulletin) so I have to do it through a plugin. The plugin hooks into the page at the very end (after the closing html) so if my plugin is

echo('<link rel="stylesheet" href="style.css">');

It ends up at the very end like

</html><link rel="stylesheet" href="style.css">

is there anyway I can target the </head> tag and insert the style sheet before it?

I have tried

$string = "</head>";
$string = str_replace("</head>", "<link rel="stylesheet" href="style.css"></head>", $string);

But that had no effect.

Sorry if I'm not asking this correctly, but I hope someone understands what I mean.