Reece Costello Reece Costello - 1 year ago 66
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.

Answer Source

Try this:

$array = ['This', 'is', 'example'];    
$stringToWrite = implode(' ', $array);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download