RSS ? Recent Blog Posts

Blogs ยป Archive for March 17th, 2004

Google API CFC

by davidjmedlock

…posted by davidjmedlock:

Well, I’ve returned from my much needed vacation, though I must admit that it’s a little difficult to get motivated again. I suppose it will take me a few days to get back into the groove. Salt Lake City was pretty cool. We went skiiing at Brighton and Park City, stayed at the Grand America (a very cool hotel), and ate at some pretty cool places.

Anyway, I was trying to catch up on my surfing since I’ve been ‘Net-less for about 5 days or so and I came across this:

http://surfmind.com/lab/cf/google/

It’s a CFC that makes use of the Google API. It’s definitely something I’ll be playing around with as soon as I get through my pile of backlogged work and as soon as I get this RSS article done. Oh, and Part 2 of my Code Reuse Blog is coming up. I haven’t forgotten. *sigh* Back to work… No rest for the coder.

 

Open Source Statistics

by Blane Warrene

Looking to research what open source and web development technologies are in use and additionally analyze them against proprietary platforms? Look no further than SecuritySpace.com - which offers a roster of free and premium research reports on market penetration of various technology platforms.

This is also a great way to see the usage levels of new revisions of technology, for instance, as part of a determination on whether to migrate to Apache 2.x from the stalwart 1.3 release.

Free reports and information on data for sale at http://www.securityspace.com/s_survey/data/index.html

 

Lazy PHP: Part 2

by Harry Fuecks

Following on from Lazy PHP: Part 1, it’s time to get lazy again, with some Lazy Evaluation.

Variable Functions
A lesser known feature of PHP is it’s ability to put a function name in a variable and call the function via the variable, as explained here in the manual.

For example, using the strtolower() function;

$function = ’strtolower’;

$string = ‘HELLO WORLD!’;

echo $function($string); // displays ‘hello world!’

Nice but what’s the point? Well recently I needed a native PHP implementation of the in built array_change_key_case() function, for PHP versions below 4.2.0 (which is when it became available). Thanks to the first user submitted comment from 05-Feb-2004, didn’t even need to engage my brain. Had this straight away;

function array_change_key_case($array, $changeCase = CASE_LOWER) {
$return = array();
foreach($array as $key => $value) {
switch($changeCase) {
case CASE_LOWER:
$return[strtolower($key)] = $value;
break;
case CASE_UPPER:
default:
$return[strtoupper($key)] = $value;
break;
}
}
return $return;
}

[small]Note the use of the $return array is because the in built implementation of array_change_key_case() eliminates duplicate keys.[/small]

But there’s a performance issue here. For each element in the array, the switch condition has to evaluated. For a large array, that could become a significant overhead. What I want is to evaluate the condition once and only once.

Here’s where a variable function can help;

function array_change_key_case($array, …

 

Sponsored Links

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.