Implode() Function ex:
The implode function is used to "join elements of an array with a string".
The implode() function returns a string from elements of an array. It takes an array of strings and joins them together into one string.
which means "Array to String conversion".
syntax:
implode (separator , array);
example:
<?php
$array = ("s","h","a","n","a","v","a","s");
$ats = implode ("-",$array);
print $ats;
?>
result;
s-h-a-n-a-v-a-s
Explode() Function ex:
The explode function is used to "Split a string by a specified string into pieces i.e. it breaks a string into an array".
which means "String to Array conversion".
Syntax:explode (separator,string,limit)
<?php
$sta = "This is Shanavas";
print_r(explode(" ",$sta));
?>
result:
Array ([0]=> This [1]=>is [2]=>Shanavas)
No comments:
Post a Comment