Esempio n. 1
-1
 /**
  * Chops down a string according to given max length, all characters beyond $maxLength is removed.
  *
  * This function is UTF8 compatible
  *
  * @param      $str
  * @param      $maxLength
  * @param bool $lengthUnitInByte
  *
  * @return string
  *
  */
 public static function stringChopdown($str, $maxLength, $lengthUnitInByte = false)
 {
     if ($lengthUnitInByte) {
         return substr($str, 0, $maxLength);
     }
     $str = UTF8::to_utf8($str);
     $len = UTF8::strlen($str);
     if ($len <= $maxLength) {
         return $str;
     }
     return UTF8::substr($str, 0, $maxLength);
 }