أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
Implode() Function
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 using a delimiter (string to be used between the pieces) of your choice.
<?php$arr = array ('I','am','simple','boy!');$space_separated = implode(" ", $arr);$comma_separated = implode(" , ", $arr);$slash_separated = implode(" / ", $arr);?>
Explode() Function
The explode function is used to "Split a string by a specified string into pieces i.e. it breaks a string into an array".
<?php$str="I am simple boy!";print_r(explode(" ",$str));?>
The implode() function returns a string from the elements of an array.
Explode() Function
The explode function is used to "Split a string by a specified string into pieces i.e. it breaks a string into an array".
The explode function in PHP allows us to break a string into smaller text with each break occurring at the same symbol. This symbol is known as the delimiter. Using the explodecommand we will create an array from a string. The explode() function breaks a string into an array, but the implode function returns a string from the elements of an array.
The different is following,
Implode()
explode()
Hope It will help.
As I think in simple terms that
implode function will generates special characters into a string. like (spaces, @, !, coma etc.).
explode did the opposite it will break or remove the special characters from string.
and in technical ways,
explode function will break down a string into more parts that will be manageable!
implode function will use to concatenate them and joined break parts to a single string again.
that's it!
Regards,
Kamal
explode() use to convert string to array
implode() use to convert array to string