Thursday, August 8, 2013

What is the difference between "implode" and "explode" in PHP?

"explode" splits a string into fragments specified by delimiter whereas "implode" conglomerates words separated by delimiter to form a string.

<html>
<head>
<title>Difference between explode and implode.</title>
</head>
<body>
<?php
$mNumber = "+91-988-620-2991";
$fragments = explode("-", $mNumber);
echo "Country Code : $fragments[0]";

echo '<br>';

$string = array("My", "name", "is", "Rabindra.");
$fullString = implode(" ", $string);
echo $fullString;
?>
</body>
</html>

No comments :