4Jean 4Jean - 2 years ago 128
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

Answer Source

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!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download