开发者

PHP remove non standard characters

开发者 https://www.devze.com 2023-03-06 14:34 出处:网络
I have text with alot of non-standard characters and they are stored like this in database: ΓΓÇôΓÇ₧ΓΓÇ&开

I have text with alot of non-standard characters and they are stored like this in database: ΓΓÇôΓÇ₧ΓΓÇ&开发者_StackOverflow#244;ΓÇ₧

Is there a way to filter them or replace them with nothing?


I would use a regular expression

echo preg_replace("/&#\\d+;/", "", $textWithWeirdCharacters);


Make an array with the non-standard characters you don't want. And then apply next code to it.

<?php
$blockChars = array('&#915', '...');
$string = str_replace($block, array_fill(0, count($blockChars), ''), $string);
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消