View Single Post
  #2  
Old 16th August 2010, 00:28
Rapid2214 Rapid2214 is offline
Senior Member
 
Join Date: Jun 2010
Posts: 105
Thanks: 3
Thanked 5 Times in 5 Posts
Lightbulb

Fixed,
I set the months using:
Code:
date(n)
Which sets it to the month date 1 - January / 12 - December.
Example array:
Code:
$retrived_months = array("6", "1", "12");
I Then ordered that array using the command below:
Code:
asort($retrived_months);
This would give the months in numerical order.
Code:
$retrived_months = array("1", "6", "12");
I then made a simple function to convert the numerical to the word:
Code:
foreach($retrived_months as $key => $value){getmonth($value)." ";}
Which resulted in:
Code:
January June December
Function
Code:
function getmonth($value)
{
switch($value){
	case '1':
	$month = "January";
	break;
	
	case '2':
	$month = "February";
	break;
	
	case '3':
	$month = "March";
	break;
	
	case '4':
	$month = "April";
	break;
	
	case '5':
	$month = "May";
	break;
	
	case '6':
	$month = "June";
	break;
	
	case '7':
	$month = "July";
	break;
	
	case '8':
	$month = "August";
	break;
	
	case '9':
	$month = "September";
	break;
	
	case '10':
	$month = "October";
	break;
	
	case 11:
	$month = "November";
	break;
	
	case 12:
	$month = "December";
	break;
	
	}
	return $month;
}
Which returned the Month 1 as January / Month 6 as June... Etc..
Just as i needed!

Is there a cleaner way of doing it?

Hope this helps anyone else trying to achive a similar thing!

Marty
Reply With Quote