/s', '//s' ]; $filterDataPost = [ '/[\s]{2,}/', ]; $data = preg_replace($filterDataPre, ' ', $data); $data = html_entity_decode($data); $data = strip_tags($data); $data = preg_replace($filterDataPost, ' ', $data); return $data; } static public function searchQuery(string $query, string $mode = 'default') { if ($mode == 'default') { // Remove single char words $words = []; foreach ((array) explode(' ', $query) as $word) { if (mb_strlen($word) > 1) { $words[] = $word; } } if ($words) { $query = implode(' ', $words); } // Remove SphinxQL special chars $query = str_replace(['\\', '/', '~', '@', '!', '"', '(', ')'], ['\\\\', '\/', '\~', '\@', '\!', '\"', '\(', '\)'], $query); // Replace query separators to the MAYBE operator $query = str_ireplace(['MAYBE'], ['__MAYBE__'], $query); $query = preg_replace('/[\W\s]+/ui', '__SEPARATOR__', $query); $query = trim($query, '__SEPARATOR__'); $query = str_ireplace(['__SEPARATOR__', '__MAYBE__'], [' MAYBE ', ' \MAYBE '], $query); } $query = trim($query); return $query; } static public function plural(int $number, array $texts) { $cases = array (2, 0, 1, 1, 1, 2); return $texts[(($number % 100) > 4 && ($number % 100) < 20) ? 2 : $cases[min($number % 10, 5)]]; } }