This document describes how to intercept string lengths in PHP. I would like to share with you the following details: many functions are provided in php, and the string truncation function is no exception, and the function is also very powerful. & Amp; lt ;? Php file encoding format for UTF-8 $ str & amp; #39; on the park boat, there's a pretty girl if something happens in the center of the lake ...... & Amp; #39; echo & amp; nbsp; mb_substr ($ str, & amp; #39; UTF-8 & amp; #39;); set here... this document describes how to intercept string lengths in PHP. I would like to share with you the following details: many functions are provided in php, and the string truncation function is no exception, and the function is also very powerful. The encoding format here must be noted that improper handling may cause garbled characters. I hope this article will help you with PHP programming. More examples of string length truncation in PHP
1. details about substr functions
Introduction: Preface today, let's take a look at how to exchange two variables in PHP without using the third variable. For more information, see the code comments. let's take a look at it. I. substr () & strlen () code: <? Php/*** when both variables are strings, you can use the exchange method 1 * use substr () and strlen () to exchange variable values */
[Related Q & A recommendations ]:
A question about javascript-codewars.
Javascript-easyui is related. is the js slice and substr methods in the formatter function invalid?
Regular expression-java obtains the subscript of the first digit in a String, and truncates the next six digits and the preceding region.
Chinese word segmentation-Chinese character traversal strings in php
Php-format conversion
The above is a detailed article about the php substr () function. For more information, see other related articles in the first PHP community!