Home >Backend Development >PHP Tutorial >PHP uses the explode() function to split a string into an array, explode array_PHP tutorial

PHP uses the explode() function to split a string into an array, explode array_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:06:23891browse

php uses the explode() function to split a string into an array, explode array

The example in this article describes how PHP uses the explode() function to split a string into an array. Share it with everyone for your reference. The specific analysis is as follows:

explode() function: split the string into an array

The sample code is as follows:

<&#63;php
$str = "朝阳区,海淀区,西城区,东城区,丰台区";
$arr = explode(",",$str);
echo "<pre class="brush:php;toolbar:false">";
print_r($arr);
&#63;>

The results are as follows:

<pre class="brush:php;toolbar:false">Array
(
  [0] => 朝阳区
  [1] => 海淀区
  [2] => 西城区
  [3] => 东城区
  [4] => 丰台区
)

Supplement:

Syntax: explode(parameter 1, parameter 2)
Parameter 1: By what to split, such as "," in the above example.
Parameter 2: The string that needs to be split.

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/959112.htmlTechArticlephp uses the explode() function to split a string into an array. The explode array example in this article describes the use of php The explode() function splits a string into an array. Share it with everyone...
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