mb_strimwidth

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_strimwidth获取按指定宽度截断的字符串

说明

mb_strimwidth ( string $str , int $start , int $width [, string $trimmarker = "" [, string $encoding = mb_internal_encoding() ]] ) : string

width字符串 str 截短。

参数

str

要截短的 string

start

开始位置的偏移。从这些字符数开始的截取字符串。(默认是 0 个字符) 如果 start 是负数,就是字符串结尾处的字符数。

width

所需修剪的宽度。负数的宽度是从字符串结尾处统计的。

trimmarker

当字符串被截短的时候,将此字符串添加到截短后的末尾。

encoding

encoding 参数为字符编码。如果省略,则使用内部字符编码。

返回值

截短后的 string。 如果设置了 trimmarker,还将结尾处的字符替换为 trimmarker ,并符合 width 的宽度。

更新日志

版本 说明
7.1.0 支持负数的 startwidth

范例

Example #1 mb_strimwidth() 例子

<?php
echo mb_strimwidth("Hello World"010"...");
// 输出 Hello W...
?>

参见

相关文章
php 多字节字符串 函数 检查字符串在指定的编码里是否有效php 多字节字符串 函数 get a specific characterphp 多字节字符串 函数 perform a regular expression search and replace with multibyte support using a callbackphp 多字节字符串 函数 replace regular expression with multibyte supportphp 多字节字符串 函数 returns start point for next regular expression matchphp 多字节字符串 函数 retrieve the result from the last multibyte regular expression matchphp 多字节字符串 函数 设置/获取当前的语言php 多字节字符串 函数 返回所有支持编码的数组php 多字节字符串 函数 get code point of characterphp 多字节字符串 函数 在输出缓冲中转换字符编码的回调函数php 多字节字符串 函数 获取按指定宽度截断的字符串php 多字节字符串 函数 查找字符串在另一个字符串中首次出现的位置php 多字节字符串 函数 查找指定字符在另一个字符串中最后一次的出现php 多字节字符串 函数 大小写不敏感地查找指定字符在另一个字符串中最后一次的出现php 多字节字符串 函数 大小写不敏感地在字符串中查找一个字符串最后出现的位置php 多字节字符串 函数 返回字符串的宽度php 字符串 函数 计算指定文件的 md5 散列值php 字符串 函数 根据指定格式解析输入的字符php 字符串 函数 转换指定字符php 多字节字符串 多字节字符串 函数
关注编程学问公众号