Reece Costello Reece Costello - 9 days ago 5
PHP Question

Write array values to file but with whitespace between each value

I want to write my array values to a file which i can do but the output ends up looking something like this:


Thisisanexample


I basically want to split every array value up to look like this:


This is an example


The array is what you would expect:

Array
(
[0] => This
[1] => is
[2] => an
[3] => example
)


I'm not sure how I could formulate this.

Answer

Try this:

$array = ['This', 'is', 'example'];    
$stringToWrite = implode(' ', $array);