+4 votes
in Programming Languages by (56.8k 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

+1 vote
by (349k points)
selected by
 
Best answer

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);

?>


...