Reece Costello Reece Costello - 1 month ago 13
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:


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

This is an example

The array is what you would expect:

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

I'm not sure how I could formulate this.


Try this:

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