How can this routine be better optimized?
<p>The routine below does two scans over an input stream of hypertext. The first pass is a spin replacement on user defined phrase options. The second pass is a find replace on the tags collection in the doReplace function below.</p>

<p>I'm just looking for suggestions on how it might be optimized. I'm having no performance issues as is. But I want to build for scalability.</p>

<pre><code>/* FIND REPLACE SPIN
--------------------------------------------------------------------*/
function doReplace($content)
{
// content is a precompiled text document formatted with html and 
// special using replacement tags matching the $tags array collection below
    $tags = array('[blog-name]', '[blog-url]', '[blog-email]');
    $replacements = array('value1', 'value2', 'value3');
    $content = str_replace($tags, $replacements, $content);
    return $content;
}

function doSpin($content) {
// the content also has phrase option tags denoted by [%phrase1|phrase2_|phrase3%]
// delimiters throughout the text.
  return preg_replace_callback('!\[%(.*?)%\]!', 'pick_one', $content);
}

function pick_one($matches) {
  $choices = explode('|', $matches[1]);
  return $choices[rand(0, count($choices)-1)];
}

$my_source_page = file_get_contents('path/to/source';}
$my_source1_spin = doSpin($my_source_page);
$my_source1_replace = doReplace($my_source1_spin);
$my_source1_final = addslashes($my_source1_replace);

//Now do something with $my_source1_final
</code></pre>
