Jack
Jack

Reputation: 3

PHP remove non standard characters

I have text with alot of non-standard characters and they are stored like this in database: ΓΓÇôΓÇ₧ΓΓÇôΓÇ₧

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

Upvotes: 0

Views: 425

Answers (2)

vidstige
vidstige

Reputation: 13085

I would use a regular expression

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

Upvotes: 1

Stijn Leenknegt
Stijn Leenknegt

Reputation: 1347

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);
?>

Upvotes: 0

Related Questions