1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\models;
- use Yii;
- use yii\base\Model;
- /**
- * ContactForm is the model behind the contact form.
- */
- class HelperModel extends Model
- {
-
- public static function stripWhitespaces($string)
- {
- $old_string = $string;
- $string = strip_tags($string);
- $string = preg_replace('/([^\pL\pN\pP\pS\pZ])|([\xC2\xA0])/u', ' ', $string);
- $string = str_replace(' ',' ', $string);
- $string = trim($string);
-
- if ($string === $old_string) {
- return $string;
- } else {
- return self::stripWhitespaces($string);
- }
- }
-
- public static function clearSectionString($string,$mask)
- {
- $result = '';
- for ($i=0;$i < mb_strlen($string); $i++) {
- $lit = mb_substr($string, $i, 1, 'UTF-8');
- foreach ( $mask as $l) {
- //var_dump($lit .'==='. $l);
- if ( $lit === $l) {
- $result .= $lit;
- }
- }
- }
- $result = mb_strtoupper($result);
- return $result;
- }
- }
|