2019-08-23 11:39:42 +00:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class Utilities
|
|
|
|
|
{
|
|
|
|
|
function cleanString($text) {
|
|
|
|
|
$utf8 = array(
|
|
|
|
|
'/[áàâãªä]/u' => 'a',
|
|
|
|
|
'/[ÁÀÂÃÄ]/u' => 'A',
|
|
|
|
|
'/[ÍÌÎÏ]/u' => 'I',
|
|
|
|
|
'/[íìîï]/u' => 'i',
|
|
|
|
|
'/[ěéèêë]/u' => 'e',
|
|
|
|
|
'/[ĚÉÈÊË]/u' => 'E',
|
|
|
|
|
'/[óòôõºö]/u' => 'o',
|
|
|
|
|
'/[ÓÒÔÕÖ]/u' => 'O',
|
|
|
|
|
'/[úùûü]/u' => 'u',
|
|
|
|
|
'/[ÚÙÛÜ]/u' => 'U',
|
|
|
|
|
'/Š/' => 'S',
|
|
|
|
|
'/š/' => 's',
|
|
|
|
|
'/Č/' => 'C',
|
|
|
|
|
'/č/' => 'c',
|
|
|
|
|
'/ř/' => 'r',
|
|
|
|
|
'/Ř/' => 'R',
|
|
|
|
|
'/Ý/' => 'Y',
|
|
|
|
|
'/ý/' => 'y',
|
|
|
|
|
'/ç/' => 'c',
|
|
|
|
|
'/Ç/' => 'C',
|
|
|
|
|
'/ñ/' => 'n',
|
|
|
|
|
'/Ñ/' => 'N',
|
|
|
|
|
'/–/' => '-', // UTF-8 hyphen to "normal" hyphen
|
|
|
|
|
'/[’‘‹›‚]/u' => ' ', // Literally a single quote
|
|
|
|
|
'/[“”«»„]/u' => ' ', // Double quote
|
|
|
|
|
'/ /' => ' ', // nonbreaking space (equiv. to 0x160)
|
|
|
|
|
);
|
|
|
|
|
return preg_replace(array_keys($utf8), array_values($utf8), $text);
|
|
|
|
|
}
|
2019-09-19 12:48:31 +00:00
|
|
|
|
|
|
|
|
|
function stringInsert($str,$insertstr,$pos)
|
|
|
|
|
{
|
|
|
|
|
$str = substr($str, 0, $pos) . $insertstr . substr($str, $pos);
|
|
|
|
|
return $str;
|
|
|
|
|
}
|
2019-08-23 11:39:42 +00:00
|
|
|
|
}
|