Home  >  Article  >  Backend Development  >  Detailed explanation of usage examples of substr() function and explode() function in php

Detailed explanation of usage examples of substr() function and explode() function in php

怪我咯
怪我咯Original
2017-07-07 10:04:181311browse

This article mainly introduces the usage analysis of substr() and explode() functions in PHP, and describes substr in more detail in the form of examples. () and explode() functions are techniques for processing strings. They are frequently used functions in string operations and have certain practical value. Friends in need can refer to this article

The example describes the usage of substr() and explode() functions in PHP. Share it with everyone for your reference. The specific method is as follows:

substr(

string,start,length): This function takes out length characters from the string starting from the start position of the string. If start is a negative number, then Counting from the end of the string, if the omitted parameter length exists but is a negative number, it means that the penultimate length character is obtained. The example code is as follows:

The code is as follows:

explode(separator,string,limit): This function splits the string into

array separator specifies where to split, string the string to be split, limit optional, the maximum number of array elements, example The code is as follows:

The code is as follows:

abc,[1]=>bck,[2]=>fhq,[3]=>nui) 
?>


The above is the detailed content of Detailed explanation of usage examples of substr() function and explode() function in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn