This article describes the use of string length interception in PHP. Share to everyone for reference, as follows: PHP provides a lot of use of functions, where the interception function of the string is no exception, and the function is very powerful. <?php//file encoding format for utf-8$str= ' on the park boat, there's a pretty girl, if something happens in the middle of the lake ... '; Echo mb_substr ($str, 0,7, ' UTF-8 ');//Set the encoding format of the display string// Output ' on the park ship, there's ' Echo mb_substr ($str, 3,7, ' UTF-8 ');//Here Set the encoding format of the display string//output ' on board, there is a drift '?> here the encoding format must be noted that improper handling may be garbled. I hope this article is helpful to you in PHP programming. More examples of truncation of string lengths in PHP
1. A detailed introduction to the SUBSTR function
Introduction: This article describes the use of string length interception in PHP. Share to everyone for reference, as follows: PHP provides a lot of use of functions, where the interception function of the string is no exception, and the function is very powerful. <? php//file encoding format for utf-8$str=& #39; on the park boat, there is a pretty girl, if something happens in the center of the lake what ......& #39;; Echo mb_substr ($str,0,7,& #39; utf-8& #39;) and/or set up here ...
2. Python Crawler Primer (5)--Regular Expression Example tutorial
Introduction: To be a crawler, the inevitable use of regular expressions, if it is a simple string processing, similar to split,substring and so on is enough, but involves a more complex match, of course, is the world, The following article mainly introduces the Python crawler of the regular expression of the relevant information, the need for friends can refer to.
3. Detailed overview of common string methods in C #
Summary: Intercepting a string uses the substring method, which has two overloaded functions in C #: substring (parameter), substring (parameter 1, parameter 2), as follows: string A = "I m a string"; String b=a.substring (1); String c=a.substring (1,6); Where the passed parameter 1 is the starting position of the string, character string B intercepts all characters after the 2nd character of the string A. Character string C will intercept the character of length 6 after the 2nd character of a
4. PHP replacement String Function instance parsing
Summary: A string substitution technique enables you to replace a specified character in a specified string. The substitution technique for strings can be implemented with two functions: the Str_irplace () function and the Substr_replace () function.
5. PHP Intercept string function substr () function instance usage detailed
Summary: A very important technique in PHP is to intercept characters of a specified length in a specified string. PHP can be implemented using the PHP predefined function substr () function for string interception.
6. Substring and substr methods in JS
Introduction: 1. Substring method definition and Usage: The substring method is used to extract the character of a string intermediary between two specified subscripts. Syntax: stringobject.substring (start,end) parameter description: Start required. A nonnegative integer that specifies the position of the first character of the substring to be extracted in the stringobject. End is optional. A nonnegative integer, than to extract
7. Several commonly used MySQL intercept functions
Summary: The commonly used MySQL interception functions are: Left (), right (), substring (), Substring_index () below one by one to illustrate: 1. Right intercept (str, length) 2. Length) 3.substring (str, POS); SUBSTRING (str, POS, len) 4.substring_index (Str,delim,count)
8. Code for an ASP.
Description://Encrypt public string desencrypt (string strText, String strencrkey) {byte[] bykey=null; byte[] iv= {0x12, 0x34, 0x56, 0x7 8, 0x90, 0xAB, 0xCD, 0xEF}; try {bykey = System.Text.Encoding.UTF8.GetBytes (strencrkey.substring (0,8)); Des
9. JavaScript String Practical Summary details
Summary: JavaScript strings are used to store and manipulate text. So at the time of writing the JS code, she always follows, when you process the user input data, when reading or setting the properties of the DOM object, when manipulating the Cookie, in the conversion of various different Date, and so on, and so on, and so on, and so on, and her full API ah, there are always some people reluctant to remember the impulse, Since the use of frequent search, rather than a rotten pen, by the way also reflects the value of the existence of the blog, thus there is this summary. String Intercept 1. SUBSTRING () Xstring.substrin.
PHP Exchange Two Variable value method (without the third variable)
Introduction: Preface Here today we will look at how in PHP without the use of the third variable, the exchange of two variables to achieve the purpose. For a detailed explanation, see the code comment below to see it together. One, substr () && strlen () code:<& #63;p hp/** * Both variables are strings, available Exchange method one * using substr () combined with strlen () two methods to achieve the swap variable worth the purpose */
"Related question and answer recommendation":
Javascript-codewars a question, do not understand
Javascript-easyui correlation, formatter function js Slice and substr method invalidation?
Regular expression-Java obtains the subscript of the first digit in a string string and intercepts the next 6-bit and previous regions
Chinese word breaker-PHP character traversal string
PHP-Format Conversion issues