I am stuck with a problem.I have an array that contains dates and I want to get the date ranges from this array.
For example array('01/01/2012','01/02/2012','01/03/2012','01/05/2012','01/10/2012')
Now I want the date range from this array
And the dates are not sorted in array. Can anyone help me its quiet urgent.
Thanks in advance.

what date ranges? its an array of dates

$array = array('01/01/2012','01/02/2012','01/03/2012','01/05/2012','01/10/2012');

foreach($array as $v){
echo $v."<br/>\r\n";


Can you please give us more detail.. to sort your array, you can easily do this by and it will give you an ordered dates regardless if you put 01/20/2012 in front of the array.

$dates_ar = array('01/01/2012','01/20/2012','01/02/2012','01/03/2012','01/05/2012','01/10/2012');

## we can echo
foreach ($dates_ar as $date => $val) {
    echo "Dates[" . $date . "] = " . $val . "\n";

If you want to find the earliest date and the last date within the array, then you can do something like this..

$dates_ar = array('01/01/2012','01/20/2012','01/02/2012','01/03/2012','01/05/2012','01/10/2012');
## first we sort the array above to make it in order
## we need to find out how many items are in the array.
## I am assuming here that the array[0] is the earliest
echo count($dates_ar)."<br/>";

## now we know how many date entries in the array, we need to pick up the last
$numb = (string)(count($dates_ar)-1);
## first date of the array
echo $dates_ar[0]."<br/>";

## the last date of the array
echo $dates_ar[$numb]."<br/>";

You can even evaluate, can convert dates to unix or whatever is needed for you to find/calculate range. The above is just a simple example from many possibilities.. It is all about how you will apply the logic that you have in your mind. It is all logic :).