Home >Backend Development >PHP Tutorial >implode and explode in php
I encountered a lot of problems when developing PHP programs, and I had some bumps and tumbles along the way, but in the end I passed five levels and defeated six generals, and all the functions that should be implemented were realized. The following two functions are a set that I have used during the development process. This set of functions mainly implements the splitting of strings and the combination of strings. Programmers are accustomed to looking at examples. Let's look at a set of examples.
Split character string function explode()
The format of the value of $row['logistics'] is similar to: 1,2,3,4,5,6,7,8
Php code
$logistics=explode(",", $row['logistics']); $count = count($logistics); for($i=0;$i<$count;$i++){ echo $logistics[$i]; }
So what I print out is 1 2 3 4 5 6 7 8.
Splicing string function implode()
Php code
<?php $arr = array('Hello','World!'); echo implode(" ",$arr); ?>
Output: Hello World!
Okay, now it’s up to you what you want to use this data for. .