+4 votes
in Programming Languages by (60.0k 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 (354k 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);

?>


...