Home > Backend Development > PHP Tutorial > implode and explode in php

implode and explode in php

巴扎黑
Release: 2016-11-12 14:27:22
Original
1815 people have browsed it

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];  
}
Copy after login

So what I print out is 1 2 3 4 5 6 7 8.

Splicing string function implode()

Php code

<?php  
$arr = array(&#39;Hello&#39;,&#39;World!&#39;);  
echo implode(" ",$arr);  
?>
Copy after login

Output: Hello World!

Okay, now it’s up to you what you want to use this data for. .


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