Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PHP
$description="Work closely with end users on any ‘agile’ projects Â";
$description=str_replace("Â", "", $description);
    $description=str_replace("€", "", $description);
    $description=str_replace("â", "", $description);
    //$current_encoding = mb_detect_encoding($text, 'auto');
    //$text = iconv($current_encoding, 'UTF-8', $text);

echo $description;



this is my code, it give me output like this

Work closely with end users on any Ëœagileâ„¢ projects

i want answer like this Work closely with end users on any agile projects
please help me...as fast
Posted
Updated 9-Jul-19 1:15am
Comments
Sergey Alexandrovich Kryukov 15-Oct-14 12:13pm    
Why removing it? You need to think how these characters got there in first place. What if you just misinterpreted the data presented in one of the UTFs? You got my big down-vote for huge technology abuse and the attempt to find a dirty work-around instead of solving the problem.
—SA

Hello, hopefully this one will work for you :)

<?php
$val = 'Work closely with end users on any ‘agile’ projects Â';
echo replaceAccents($val); 

function replaceAccents($str)
{
    $a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í',
               'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü',
               'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë',
               'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û',
               'ü', 'ý', 'ÿ', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ',
               'ċ', 'Č', 'č', 'Ď', 'ď', 'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę',
               'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ', 'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ',
               'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ',
               'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', 'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń',
               'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő', 'Œ', 'œ',
               'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', 'Ş', 'ş', 'Š', 'š',
               'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', 'ŭ', 'Ů', 'ů',
               'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż', 'ż', 'Ž',
               'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ', 'Ǔ',
               'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ',
               'ǿ', '€', '™', '˜');
    $b = array('');
    return str_replace($a, $b, $str);
}
?>
 
Share this answer
 
v2
Comments
Chirag jakhariya 17-Oct-14 11:50am    
thank you for helping me in this situation...
Use a regular expression replace, with acceptable characters in an exclude-these form of a match:

http://php.net/manual/en/function.preg-replace.php[^]

replace undesired chars with empty string, space, or whatever.
 
Share this answer
 
Comments
Chirag jakhariya 17-Oct-14 11:50am    
thank you
you can try this method also it will be much helpful

To remove â character from string

mysqli_set_charset($con,"utf8");

$price = "₹ 250.00";

$price2 = preg_replace('/[^(\x20-\x7F)]*/','', $price);

Result : 250.00


this helps to remove character like ‘ €™ " from string.

Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900