:::

6-13 function_block.php

<?php
if (!function_exists('word_cut')) {
    function word_cut($string, $limit, $pad = "...")
    {
        $len = mb_strlen($string, 'UTF-8');
        if ($len <= $limit) {
            return $string;
        }

        //先找出裁切後的字串有多少英文字
        $tmp_content = mb_substr($string, 0, $limit, 'UTF-8');
        preg_match_all('/(\w)/', $tmp_content, $match);
        $eng = count($match[1]);
        $add = round($eng / 2, 0);
        $limit += $add;
        $string = mb_substr($string, 0, $limit, 'UTF-8');

        return $string . $pad;
    }
}

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Fmail.tad0616.cp22.secserverpros.com%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1478%26tbsn%3D44

書籍目錄

展開 | 闔起

線上使用者

232人線上 (85人在瀏覽線上書籍)

會員: 0

訪客: 232

更多…