<?php
function stripSpecialCharater($string)
{
return preg_replace(['/\s{2,}|[\t\R]/u', '/[^a-z\d\s&‚~§©ÂÃ⃀-]/ui'], [' ', ''], $string);
//$string = iconv("Windows-1252","UTF-8",urldecode($string));
//$string = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $string);
//return preg_replace('/[^a-zA-Z0-9ç&-©‚ƒ‘\s]/', '', $string);
}
$tests = ['12 34', 'adsf', 'co©', 'pound £'];
foreach ($tests as $test) {
echo "$test : ";
var_export(stripSpecialCharater($test));
echo "\n";
}
- Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- 12 34 :
Warning: preg_replace(): Compilation failed: escape sequence is invalid in character class at offset 11 in /in/VvVcc on line 4
NULL
adsf :
Warning: preg_replace(): Compilation failed: escape sequence is invalid in character class at offset 11 in /in/VvVcc on line 4
NULL
co© :
Warning: preg_replace(): Compilation failed: escape sequence is invalid in character class at offset 11 in /in/VvVcc on line 4
NULL
pound £ :
Warning: preg_replace(): Compilation failed: escape sequence is invalid in character class at offset 11 in /in/VvVcc on line 4
NULL
- Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
- 12 34 : '12 34'
adsf : 'adsf'
co© : 'co©'
pound £ : 'pound '
preferences:
140.53 ms | 408 KiB | 5 Q