A few issues going on here.
Firstly; in your match expression; you are trying to match against the closing HTML tag </i>. Unfortunately; the forward slash character delimits the match component from modifier codes that can change the behaviour of the regular expression parser. Therefore, it is necessary to escape the forward-slash in the match expression using the back slash.
Secondly; in order for the second parameter to preg_replace to be processed as PHP code, you need to use the "e" modifier in the match expression. A modifier (see previous paragraph) is included in the match expression at the end, preceeded by the forward slash character. Overall, the match expression you need is:
'/<i>([a-zA-Z0-9 ]*)<\/i>/e'
Finally; in order for the second parameter to be processed as PHP code it must be a string value containing PHP, not actual PHP itself... The code must return a string when evaluated; in other words it must start and end with either double or single-quotes. Any other double-or single quotes within the string must be escaped if required. I think the match expression that should work for what you want to do is:
'"<a href=\'".str_replace(" ","_","$1").".html\'>$1</a>"'
Overall, this makes your final code:
PHP Code:
$mystring = preg_replace('/<i>([a-zA-Z0-9 ]*)<\/i>/e', '"<a href=\'".str_replace(" ","_","$1").".html\'>$1</a>"', $mystring);
Note that this removes the italic tags. If you want to keep the italics you will need to include them in the replacement string.
Hope that works.....