Solve wordpress's problem of garbled characters when using mb_strimwidth to intercept the title length. [original]

Source: Internet
Author: User
Mb_strimwidth (PHP4 & gt; = 4.0.6, PHP5) mb_strimwidth & mdash; returns the stringmb_strimwidth (string $ str, int $ start, int $ width [, string $ trimmarker [

 

Mb_strimwidth

 

(PHP 4> = 4.0.6, PHP 5)

Mb_strimwidth-get the string truncated by the specified width

Description

String mb_strimwidth (string $ str, int $ start, int $ width [, string $ trimmarker [, string $ encoding])

Truncate the str string by pressing width.

 

Parameters

 

 

Str

The string to be truncated.

Start

The start offset. A string starting from the number of characters. (0 characters by default)

Width

The width of the trim.

Trimmarker

When the string is truncated, add it to the end of the string after the string is truncated.

Encoding

The encoding parameter is character encoding. If omitted, internal character encoding is used.

 

Return value

 

 

The truncated string. If trimmarker is set, the trimmarker is appended to the returned value.

 

Example

 

 

 

 

Example #1 mb_strimwidth () Example

Echo mb_strimwidth ("Hello World", 0, 10 ,"...");

// Output Hello W...

?>

Solve the garbled characters in WordPress using the mb_strimwidth function!

1. Enable the mb_string extension service of the apache server.

2. string mb_strimwidth (string $ str, int $ start, int $ width [, string $ trimmarker [, string $ encoding])

Use the encoding parameter to set the character encoding.

Example:

Echo mb_strimwidth ("io100-Knowledge Base", 0, 10, "...", [backcolor = transparent] "UTF-8 ");

?>

Reprinted please indicate the source: http://www.ios100.net/open/wordpress/49.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.