RE: [PHP] Sorting a text string

From: Date: Thu, 05 Sep 2002 08:49:40 +0000
Subject: RE: [PHP] Sorting a text string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-115282@lists.php.net to get a copy of this message
Hi There. One way of doing this: split each string into an array, delimited by the periods $sDate = '04.09.2002'; $aDate = split( '.', $sDate ); this will give you an array like array( [0]=>'04', [1]=>'09', [2]=>'2002' ) now reverse the array: $aDate = array_reverse( $aDate ); join back into a string, using periods: $sDate = join( '.', $aDate ); $sDate => '2002.09.04' HTH Regards -|Scott > -----Original Message----- > From: Bård Tommy Nilsen [mailto:bard.tommy.nilsen@svt.ntnu.no] > Sent: Thursday, September 05, 2002 10:36 AM > To: 'php-general@lists.php.net' > Subject: [PHP] Sorting a text string > > > > I want to sort text strings, but how could i do this ? > > Example: > > 04.09.2002 > 05.09.2002 > 19.03.1999 > > > Is there a way to "change" the string to something like this ... > > 2002.09.04 > 2002.09.05 > 1999.03.19 > > Or is there a better way to solve this ?? > > > Bård Tommy Nilsen > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#115282) next »