Putting double spaces instead of single spaces

Posted on 16th Feb 2014 by admin

Im looking at trying to replace all single spacing between fields with double spacing

At present my file looks like this

3 Caxxxan Maxxxet Waxxxxe Axxxxxxy Co.Kildare

but after the double spacing, I want it to look like

3 Caxxxan Maxxxet Waxxxxe Axxxxxxy Co.Kildare

The code I have so far is

Code: <?php
$fields=file('C:UsersMikeDesktop5april.txt');
foreach($fields as $i=>$field)
{
$field=str_replace(' ',',',$field);
$field=str_replace(' ',',',$field);
$fields[$i]=$field;
}
file_put_contents('C:UsersMikeDesktoptest.txt',implode("r",$fields));
?>

Any help would be great

Other php-forum