This article mainly introduces PHP using the explode () function to split the string into an array of methods, with a certain reference value, the need for friends can refer to the
This example describes how PHP uses the explode () function to split strings into arrays. Share to everyone for your reference. The specific analysis is as follows:
Explode () function: string split into an array
The sample code is as follows:?
|1 2 3 4 5 6||<?php $str = "Chaoyang District, Haidian District, Xicheng District, Dongcheng District, Fengtai District"; $arr = Explode (",", $str); echo "<pre>"; Print_r ($arr);?>|
The results are as follows:?
|1 2 3 4 5 6 7 8||<pre>array ( => Chaoyang District  => Haidian District  => Xicheng District  => Dongcheng District  => Fengtai District)|
Syntax: Explode (parameter 1, parameter 2)
Parameter 1: What to split, as in the example above,.
Parameter 2: A string that needs to be split.
I hope this article will help you with your PHP program design.