This article mainly introduces the usage of the PHP string splitting function. It analyzes the usage skills of the explode and split functions in PHP with examples. It is of great practical value. Friends who need it can refer to it.
The examples in this article describe PHP string split function usage. The specific analysis is as follows: The explode and split functions in
php are used to split strings.
explode function syntax is as follows
explode(substring, string)
explode function splits through substrings, and is more efficient than split. The split function syntax is as follows
split(pattern, string)
split uses regular expressions to split strings For segmentation, the efficiency is lower than explode, but the function is powerful
<?php $list = explode("_","php_strting_function.html"); print("explode() returns:\n"); print_r($list); $list = split("[_.]","php_strting_function.html"); print("split() returns:\n"); print_r($list); ?>
The output results are as follows:
explode() returns: Array ( [0] => php [1] => strting [2] => function.html ) split() returns: Array ( [0] => php [1] => strting [2] => function [3] => html )
Summary: The above is the entire content of this article, I hope it can help Everyone’s learning helps.
Related recommendations:
Application of PHP file operation function
##php implements SMS verification code for checking mobile phone number and IMEI
php implements SMS verification code for checking mobile phone number and IMEI
The above is the detailed content of How to use php string splitting function. For more information, please follow other related articles on the PHP Chinese website!