0

How can i replace the cyrilian sign Ѓ with a <br />?

This one doesn't work:

$card = str_replace('Ѓ ', '<br />', $card);

This one doesn't work either:

$card = str_replace( array('ѓ', 'Ѓ'),'<br />', $card )
Paul R
  • 208,748
  • 37
  • 389
  • 560
  • A combination of [mb_strpos()](http://www.php.net/manual/en/function.mb-strpos.php) and [mb_substr()](http://www.php.net/manual/en/function.mb-substr.php) then concatenating it all together again? – Mark Baker Jul 26 '13 at 13:08

2 Answers2

1

Just few minutes ago searched for same function and found one from PHP.net comments that works for me.

Try this.

function mb_str_replace($needle, $replacement, $haystack) {
    $needle_len = mb_strlen($needle);
    $replacement_len = mb_strlen($replacement);
    $pos = mb_strpos($haystack, $needle);
    while ($pos !== false)
    {
        $haystack = mb_substr($haystack, 0, $pos) . $replacement
                . mb_substr($haystack, $pos + $needle_len);
        $pos = mb_strpos($haystack, $needle, $pos + $replacement_len);
    }
    return $haystack;
}
Sergei Beregov
  • 738
  • 7
  • 19
0

This code works (see http://ideone.com/hE72xA):

<?php
    $card = "Hello Ѓ";
    echo str_replace("Ѓ","<br/>",$card);
?>

output: Hello <br/>

tomsullivan1989
  • 2,760
  • 14
  • 21
  • As the standard string functions aren't written to work with multibyte character sets, this isn't guaranteed – Mark Baker Jul 26 '13 at 13:22