Particularly Microsoft Visio. I know that the product itself is a great product. And I know it does exactly what it is said to do.
My struggle with the application at the moment centers around the fact that everything you could possibly want out of a UML diagramming tool is present in Visio. Except the UML stuff.
That is something that Microsoft feels is better left to the professional version of Visio. Which means that after much wailing and gnashing of teeth I am still stuck with a product that I cannot use to do what my client needs me to do. Crap.
Sometimes Microsoft makes me want to hit them in the face. The open source alternatives that I have used for just about everything have never made me jump through the hoops that M$ does. Why can’t they just buy Yahoo! already and fold so the world can be a better place?
Today a friend of mine asked me if I knew of a way to find the next 12 months (starting with next month) and returning an array of those months and their corresponding year. I told him that I was certain that I could do something like this and set out to do it. I came up with:
<?php
/**
* Gets the next 12 months of the year, starting again at January.
*
* This function will return an array of 'month year' for the next twelve months
*
* @access public
* @return array Array of month and year strings
*/
function getNextMonths() {
/**
* Get this month by number
*
* Using the numeric value of the month allows for easy transposition into a
* new array.
*/
$tm = date('n');
/**
* Get this year - because we will need this for the string output
*/
$ty = date('Y');
/**
* Array of months keyed at 1
*
* These are keyed at 1 because the date() function does this
*/
$ms = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
/**
* Create a variable to hold out output array
*/
$ma = array();
/**
* Now build the array, using only one loop
*/
for ($j = 1, $i = $tm; $j <= 12; $i++, $j++, $ma[$j] = $i <= 12 ? "$ms[$i] $ty" : $ms[$i-12].' '.($ty+1));
/**
* Send back what we just made
*/
return $ma;
}
/**
* Output control - for the record, I do not count this as a line of code :-)
*/
header('Content-Type: text/plain');
/**
* Test it
*/
var_dump(getNextMonths());
?>
Thinking that I had found the promise land with the awesome little bit of my brainy goodness I posed this problem to my coworker as a code challenge (we do that from time to time to keep our brains thinking). To my surprise and glee, my coworker came through and kick my sorry ass all over the place with his little piece of goodness (I added the comments):
<?php
/**
* Gets the next 12 months from this month
*
* @return array Array of "month year" strings
*/
function getNextMonths() {
for ($i = 1; $i < 13; $i++) {
$array[] = date('F Y', mktime(0, 0, 0, date('m') + $i, 1, date('y')));
}
return $array;
}
// Test it
var_dump(getNextMonths());
?>
Arrogance is of the devil and I think I have taken my fair share of it. Congrats Jason, you put me in my place. And Mark is now a little happier too because you totally gave him some kick ass code.
Now to open the discussion a tad… which one do you like and why? Comment away. I would be interested to see your comments.
According to an article today by TechCrunch, Zend Technologies, The PHP company, is cutting 25% of their PHP developer staff, perhaps with an eye towards selling the company.
Israeli startup Zend Technologies has fired 25 percent of its R&D team (at least ten people), as well as others across the company, in an attempt to become cash flow positive, says a source close to the company. A spokesperson from the company’s PR firm says: “Yes, I can confirm that Zend made the layoffs, but we cannot comment on the numbers or reasons for the action.”
Read the complete TechCrunch article here.
As I read the brief article I began to think that this is not really anything that should be too newsworthy. Many companies in the USA, and around the world in general, are feeling the pinch of a down economy. Companies have to do what they can to reduce cost while maintaining competitive prices for goods and services. What Zend is doing is not really that out of the ordinary.
And I am not sure that Zend, as a company, is really worth a huge amount of money like the Sun Microsystems acquisition of MySQL was. It might be tasty to some of the players in the industry right now like Oracle, IBM or even a Sun. But really, other than the Zend engine and the Zend IDE what exactly does Zend have to offer?
Whatever happens to Zend from all of this one thing is very important to remember. Many a PHP developer now has the opportunity to seek gainful employment from other companies that are seeking, heavily, PHP talent. Many Silicon Valley companies, including many companies in the social networking space, are looking for top tier PHP talent right now. Companies like Ning, Digg, Facebook, Technorati, Yahoo and Google are constantly hiring PHP developers.
Times are good for being a PHP developer. Maybe not so much if you worked for Zend. Nonetheless, now is a great time to know a great deal about PHP.