+4 votes
in Programming Languages by (6.2k points)

How can I convert elements of an array to a string?

E.g.

From

$arr = array('Hello!!!', 'How', 'Are', 'You!');

to 

Hello!!! How Are You!

1 Answer

0 votes
by (25.6k points)

You can use either the implode() or join() function to convert the elements of an array to a string.

Here is an example:

<?php

$arr = array('Hello!!!', 'How', 'Are', 'You!');
echo implode(" ",$arr);
echo join(" ",$arr);

?>

...