Hi all,
I have a string and it contains more than one '-' character. I am trying to figure out a way to skip the first occurance of this character but change the rest of them. Anyone have any idea how to do this?
Thanks
-- tarja
Finding a character, but skipping the first found character
Moderator: General Moderators
If i understood correctly, you want to replace all "-" characters except first, then
Haven't tested, but hope it works
Code: Select all
function my_replace($search, $replacement, $string)
{
$pos = strpos($string, $search);
if ($pos === false) return $string;
$pos++;
return substr($string,0,$pos).str_replace($search, $replacement, substr($string, $pos));
}