Sounds like you've solved it already, but the problem is neatly split into a preg_match and a str_replace. The preg_match may be more flexible than loading elements into an array as you describe you've done, but it does also requires a knowledge of regular expressions to understand how it works.
preg_replace cannot be used to achieve this result in one step because it can't handle flexible length positive-look-behinds. It can replace one occurrence of - but not multiple occurrences (unless it's put in a while loop, which would be another option).
<?
$strings = array("mysite/tim/here-is-something.html",
"mysite/a/some-thing.html");
foreach ($strings as $string) {
if (preg_match("#^(mysite/tim/)(.*)#",$string,$matches)) {
print "Changed string: $string\nto: ";
print $matches[1].str_replace("-","+",$matches[2])."\n";
} else {
print "Didn't change string: $string\n";
}
}
Output:
Changed string: mysite/tim/here-is-something.html
to: mysite/tim/here+is+something.html
Didn't change string: mysite/a/some-thing.html