I'm looking for a variation of str_ireplace .. where only one definition of search phase (e.g. ALPHA) is needed to replace any variation of upper case / lower case (e.g. ALPHA or alpha or Alpha or AlPhA or aLpHa). I don't want to define all possible variations of spelling in $search array. e.g. 'ALPHA, 'alpha', 'Alpha'
Would preg_replace (case insensitive regex) be better for this?
<?php
$haystack = "alpha beta gamma delta lambda ALPHA BETA GAMMA DELTA LAMBDA";
$br = '<br />';
$search = array('ALPHA','BETA');
$count = count ($search);
// wrap $search in font tags
for ($i=0; $i < $count; $i++)
{
$replace[$i] = '<b><font color="blue">' . $search[$i] . '</font></b>';
}
// case insensitive version of str_replace
$haystack = str_ireplace($search, $replace, $haystack, $count);
echo $haystack;
?>