PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / vendor / averta / core / src / Utility / Trim.php

Trim.php in Depicter — Popup & Slider Builder trunk, at vendor/averta/core/src/Utility/Trim.php

26 lines 620 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Averta\Core\Utility;
3
4 class Trim
5 {
6 /**
7 * Trim string by character length.
8 *
9 * @param $string
10 * @param int $max_length
11 * @param string $more
12 *
13 * @return string
14 */
15 public static function text( $string, $max_length = 1000, $more = " ..." ){
16 $string_length = function_exists('mb_strwidth') ? mb_strwidth( $string ) : strlen( $string );
17
18 if( $string_length > $max_length && ! empty( $max_length ) ){
19 return function_exists( 'mb_strimwidth' ) ? mb_strimwidth( $string, 0, $max_length, '' ) . $more : substr( $string, 0, $max_length ) . $more;
20 }
21
22 return $string;
23 }
24
25 }
26