How to remove "�" from php string?

Possible duplicate:
How to replace � in a string

I am reading data from an XML sheet coming out of a database. In the raw output, I go over this “�” character, which is a UTF-8 string meaning "". Performing a simple search and delete with str_replace does not do the trick when searching for "" or "�". Is there any other way to remove this character from a string?

UPDATE:

For reference, this is a function that clears strings for me.

function db_utf8_convert($str) { $convmap = array(0x80, 0x10ffff, 0, 0xffffff); return preg_replace('/\x{EF}\x{BF}\x{BD}/u', '', mb_encode_numericentity($str, $convmap, "UTF-8")); } 
+4
source share
2 answers

You can do it:

 $str = 'UTF-8 string meaning "�"'; echo preg_replace('/\x{EF}\x{BF}\x{BD}/u', '', iconv(mb_detect_encoding($str), 'UTF-8', $str)); 

Output: UTF-8 string meaning ""

+3
source

You can do something similar to this:

 <?php $string = "asd fsa fsaf sf � asdfasdfs"; echo preg_replace("/[^\p{Latin} ]/u", "", $string); 

Look at this script for more matches:
http://www.regular-expressions.info/unicode.html#script

EDIT

I found this, people say it works, you can try:

 <?php function removeBOM($str=""){ if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) { $str=substr($str, 3); } return $str; } ?> 
+2
source

All Articles