A detailed introduction to the SUBSTR function

Source: Internet
Author: User
Tags php programming php tutorial
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. Example of a truncated use of string lengths in PHP

Introduction: This article mainly introduces the use of string length in PHP, combined with the example of the MB_SUBSTR function to intercept the Chinese strings related operation skills and considerations, the need for friends can refer to the following

2. substr function string interception usage analysis in PHP

Introduction:: This article mainly introduces PHP substr function string interception usage analysis, for PHP tutorial interested students can refer to.

3. PHP removes the last character of the string with the use of substr and MB_SUBSTR

Summary: substr:php remove the last character of the string with the use of substr and Mb_substr: Pass string: Original string: 1,2,3,4,5,6, This string: 1,2,3,4,5,6, toward the last character of the Lost "," remove the last character "," and the end result is 1,2,3,4,5,6, $str = "1,2,3,4,5,6,"; $newstr = substr ($str, 0,strlen ($STR)-1); Echo $newstr; Kanji string: Original string: Wuzhou remove the last Chinese character "City", the end result is Wuzhou

4. PHP MD5 under the 16-bit and 32-bit implementation code

PHP MD5 encrypted 16-bit and 32-bit implementation code, a search on the internet there are many people have this confusion, and later found a solution, is correct, recorded

5. PHP Interception of Chinese characters garbled problem solving method application of MB_SUBSTR function

Introduction: PHP Interception of Chinese characters garbled problem solving method mb_substr function application: first 1. Make sure you have php_ under your windows/system32. Mbstring.dll This file, do not copy from your PHP installation directory extensions into windows/system32 inside. 2. In the Windows directory find php.ini open edit, search Mbstring.dll, find; Extension=php_mbstring.dll the first, the number is removed so that the MB_SUBSTR function can take effect MB_STR

"Related question and answer recommendation":

PHP-Uses substr to appear with use of undefined constant 0-assumed ' 0 '

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.