How to strip all special symbols/characters from string for save to mysql database

/***
* Function for delete utf special symbols.
    Units of measure:
        \x{00B0} for the degree symbol.
        \x{2103} for the degree celsius symbol.
        \x{2109} for the degree fahrenheit symbol.
        \x{23CD} for the square foot symbol.
        \x{32CC} to \x{32CE} for units symbols.
        \x{3300} to \x{3357} for ideographic units symbols.
        \x{3371} to \x{33DF} for more units symbols.
        \x{33FF} for the gallon symbol.

    Ideograph radicals, strokes, symbols, and descriptors:
        \x{2E80} to \x{2EF3} for CJK radicals.
        \x{2F00} to \x{2FD5} for KangXI radicals.
        \x{2FF0} to \x{2FFB} for ideographic descriptors.
        \x{3037} to \x{303F} for miscellaneous ideographic indicators.
        \x{3190} to \x{319F} for ideographic annotation marks.
        \x{31C0} to \x{31CF} for CJK strokes.
        \x{32C0} to \x{32CB} for ideograph month symbols.
        \x{3358} to \x{3370} for ideograph time symbols.
        \x{33E0} to \x{33FE} for ideograph day symbols.
        \x{A490} to \x{A4C6} for YI radicals.

***/
function removeSpecSymbols($text = '')
    {
        $units = '\x{00B0}\x{2103}\x{2109}\x{23CD}';
        $units .= '\x{32CC}-\x{32CE}';
        $units .= '\x{3300}-\x{3357}';
        $units .= '\x{3371}-\x{33DF}';
        $units .= '\x{33FF}';

        $ideo = '\x{2E80}-\x{2EF3}';
        $ideo .= '\x{2F00}-\x{2FD5}';
        $ideo .= '\x{2FF0}-\x{2FFB}';
        $ideo .= '\x{3037}-\x{303F}';
        $ideo .= '\x{3190}-\x{319F}';
        $ideo .= '\x{31C0}-\x{31CF}';
        $ideo .= '\x{32D0}-\x{32FE}';
        $ideo .= '\x{3358}-\x{3370}';
        $ideo .= '\x{33E0}-\x{33FE}';
        $ideo .= '\x{A490}-\x{A4C6}';

        $text = preg_replace('/\p{So}(?<![' . $units . $ideo . '])/u', ' ', $text);

        return $text;
    }

$text = removeSpecSymbols($text);

How to set right page encoding using PHP (UTF-8 HTTP header)?

Quite frequently, many are faced with the problem: incorrect definition of the browser page coding.
The easy way to fix it – set the right page encoding by PHP.
Example (we use the encoding utf-8) ↓

<?php
header('Content-Type: text/html; charset=utf-8');
/*....*/
?>

Additionally, you can specify the encoding using HTML
Continue reading How to set right page encoding using PHP (UTF-8 HTTP header)?