4Jean 4Jean - 1 year ago 47
PHP Question

What is the difference between implode and explode

Please what is the meaning of implode and explode functions in php
I did not understand how it was explained in these questions explode and implode - Codeigniter and explode and implode


The explode() function breaks a string into an array.

$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));

Return: Array ( [0] => Hello [1] => world. [2] => It's [3] => a [4] => beautiful [5] => day. )

The implode() function returns a string from the elements of an array.

$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr);

Return: Hello World! Beautiful Day!