Reply to Re: Swap 2007-03-15 to 15-03-2007

Your name:

Reply:


Posted by Rik on 03/16/07 18:31

On Fri, 16 Mar 2007 19:15:31 +0100, Krustov <me@privacy.net> wrote:

> 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 =3D explode('-',$string);
array_reverse($date_array);
$string =3D implode('-',$date_array);

But as it is a textfile:

$oldfile =3D '/path/to/old/file';
$newfile =3D '/path/to/new/file';
$old =3D fopen($oldfile,'r');
$new =3D fopen($newfile,'w');
while($data =3D fscanf($old,"%s-%s-%s\n")){//change according to format
array_reverse($data);
fwrite($new,implode('-',$data)."\n");
}
-- =

Rik Wasmus

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация