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:[EMAIL PROTECTED]]
> Sent: Thursday, September 05, 2002 10:36 AM
> To: '[EMAIL PROTECTED]'
> 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
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to