- preg_quote: documentation ( source)
- preg_replace: documentation ( source)
<?php
$searchTerm = "ΓΌ";
$replaceTerm = "%FC";
$test=array("${searchTerm}/${searchTerm}_.${searchTerm}", "xay${searchTerm}", "asdasd/${searchTerm}.mp3", "${searchTerm}.", "blahahbasd${searchTerm}", "1234${searchTerm}1234");
foreach ($test as $t)
echo "$t => " . preg_replace("/". preg_quote($searchTerm) . "/x", preg_quote($replaceTerm) , $t) . "\n";