On Fri, 16 Mar 2007 19:15:31 +0100, Krustov <me@privacy.netwrote:
Swap 2007-03-15 to 15-03-2007
Given i have 50,000 dates in a text file to change i'm looking for the
fastest way of doing it .
Fastest way, if the format is consistent:
$date_array = explode('-',$string);
array_reverse($date_array);
$string = implode('-',$date_array);
But as it is a textfile:
$oldfile = '/path/to/old/file';
$newfile = '/path/to/new/file';
$old = fopen($oldfile,'r');
$new = fopen($newfile,'w');
while($data = fscanf($old,"%s-%s-%s\n")){//change according to format
array_reverse($data);
fwrite($new,implode('-',$data)."\n");
}
--
Rik Wasmus