Summary of individual methods for PHP,JS,CSS string interception

Source: Internet
Author: User
Tags php language

The following is a summary of individual methods of PHP,JS,CSS string interception, for the great god may be no content, for less spray Oh, of course, you can learn to enhance your programming ability.

650) this.width=650; "src=" Http://183.61.143.148/group1/M00/02/34/tz2PlFQpDbnToBK5AAE8yFwEKBY564.png "height=" 218 "Width=" 315 "/>

The first is the PHP version.

In fact, only with mb_strimwidth a function can be, the description of the function is as follows:
mb_strimwidth-Gets the string truncated by the specified width
string Mb_strimwidth (string $str, int $start, int $width [, String $trimmarker = "" [, String $encoding = Mb_internal_encoding ()]])
parameter Description:
$str is the string to truncate (that is, the original string, the output string)
$start intercept from the first few characters, the default is 0
$width the width of the trim you want
after the $trimmarker is intercepted, the content that is added at the end of the string (Common for ... = omitted), default I I empty
$encoding This parameter is important, if the string is in Chinese, be sure to add it. Otherwise.... You can see "" This thing, did not carefully read this function, in WordPress theme because to show a small piece of content, and then the end of garbled, and for a long time do not know why. In addition, this parameter should be consistent with the encoding format of the Web page, when the individual test page encoding utf-8, parameters written as GBK when the Chinese characters will shit. (Daniel explains)
PHP version of this, and sometimes think it is a PHP language problem, but we did not carefully study it.

JS version of:

SUBSTRING () and substr () method, two methods * almost * no difference,
The first parameter of the substring () method is required, for the position of the first character of the substring to be extracted in the string, and the second parameter is optional, which is the position of the last character of the substring to be extracted in the Stringobject 1 bits, the default none, to the end of the string.
SUBSTR () The first parameter is required. The starting subscript for the substring to extract. Must be numeric. If it is a negative number, the argument declares the position from the end of the string. That is,-1 refers to the last character in the string, 2 refers to the second-lowest character, and so on. The second parameter is optional. The number of characters in the substring. Must be numeric. If this argument is omitted, then the string from the beginning of the stringobject to the end is returned.
Example:

This example output: Hello world!
starting from the third bit of the original string, to the end

This example output: Hello world!
starting from the fourth bit of the original string, to the seventh bit

Output: Hello world!
The third place begins to the end

Output: Hello world!
starting from the fourth position, intercept 7 bits.

The third one is CSS.
CSS interception primarily uses the Text-overflow attribute.
text-overflow: [clip | ellipsis |]

The default value of Text-overflow is clip, which cuts out the excess text when the content is out of the container, and when the value is ellipsis, it replaces the excess text with an ellipsis, or you can substitute a specific string for the excess text (currently Firefox only).

Examples of ellipses:

. ellipsis{
Overflow:hidden;
White-space:nowrap;
Text-overflow:ellipsis;

}

want to know more Programming Language Tutorials knowledge can be logged in E Mentor network.


This article is from the "Add Language" blog, please make sure to keep this source http://yuguotianqing.blog.51cto.com/9292883/1560863

Summary of individual methods for PHP,JS,CSS string interception

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.