How To Use PHP Implode and Explode

How To Use PHP Implode and Explode
How To Use PHP Implode and Explode is function php for join elements of an array with a string.

PHP implode() function returns a string from elements of an array, the following example.

<html> 
<body> 
<h3>Implode Function delimeter comma</h3> 
<?php 
$arr=array ('a','b','c'); 
echo implode(",",$arr); 
?> 
</body> 
</html>  

Output code:
a,b,c


PHP explode() function is used to "Split a string by a specified string into pieces breaks a string into an array".


<html> 
<body> 
<h3>Implode Function delimeter comma</h3> 
<?php 
$arr='a b c'; 
$result = explode(",",$arr); 
?> 
</body> 
</html> 

Output code display with print_r

<?php print_r($result); ?>

array([0]=>a,[1]=>b.[2]=>c);

Lebih baru Lebih lama

نموذج الاتصال