Home > Backend Development > PHP Tutorial > PHP method to decompose characters into multiple strings, php characters multiple strings_PHP tutorial

PHP method to decompose characters into multiple strings, php characters multiple strings_PHP tutorial

WBOY
Release: 2016-07-13 10:13:20
Original
1083 people have browsed it

PHP method to decompose characters into multiple strings, php characters multiple strings

The example in this article describes how PHP decomposes characters into multiple substrings. Share it with everyone for your reference. The specific implementation method is as follows:

Decomposing a string is mainly implemented through the Split() function, which is used to decompose a string into multiple substrings using specified characters and store them in an array respectively. Its syntax is declared as follows:
array split(string pattern,string str[,int limit]);
Parameters:
pattern: used to specify the symbol as the decomposition identifier. Note that this parameter is case-sensitive.
str: The string to be processed.
limit: Returns the maximum number of decomposed substrings. By default, all substrings are returned.

An example is as follows:

Use the split() function to decompose the string "2006-10-12 16:50:49" into year, month, day, hour, minute and second substrings. The program code is as follows:

Copy code The code is as follows:
$date="2006-10-12 16:50:49";
list($year,$month,$day,$hour,$minute,$second)=split('[-: ]',$date);
echo "Beijing time: {$year}year{$month}month{$day}day{$hour}hour{$minute}minute{$second}second";
?>

The running result of this example is: Beijing time: October 12, 2006 16:50:49

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/916062.htmlTechArticlePHP’s method of decomposing characters into multiple strings, php characters multiple strings This article describes how PHP will A method of decomposing characters into multiple substrings. Share it with everyone for your reference. Specific implementation...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template