I have been looking around all night and just found something on bugs.php.net:
function str_replaceFirst($s,$r,$str)
{
$l = strlen($str);
$a = strpos($str,$s);
$b = $a + strlen($s);
$temp = substr($str,0,$a) . $r . substr($str,$b,($l-$b));
return $temp;
}
this does what i was looking for.
Thanks for your help!