"I'm a network admin by day and a PHP freelancer by night," Jarod writes. "It works pretty well. My clients (all two of them) assign me low-priority, get-it-done-whenever type projects, and I do my best to deliver 'soon' rather than 'later'. "
"During the day job, I got a handful of calls from an unrecognized number. When I finally had a chance to call back, it was a referral who was in 'very desperate' to fix his application. Apparently, they hired a graphic design shop to build them a CMS site, and it was slow as molasses. They spent weeks trying to improve things, but it just got worse. Fortunately, I was able to look at it that evening, and after digging through the project, I isolated the problem. It was coming from an addressbook view; their addressbook had 120,000 entries, and displayed 50 at a time,"
function getAlphabetList($list = null)
{
$alphabet = split(' ', 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z');
foreach($alphabet as $letter)
{
$has_letter = false;
if(is_array($list))
{
foreach ($list as $value)
{
if(substr(strtoupper($value),0,1) == strpos($letter,$value,1))
{
$has_letter = true;
}
}
}
if($has_letter)
{
$output .= '<a href="?letter='.$letter.'">'.$letter.'</a> ';
} else {
$output .= $letter.' ';
}
}
return $output;
}
Jarod added, "in most cases this is just plain bad practice. But when checking 120,000 in the addressbook 26 times to generate a link list at the top of the addressbook view, it was definitely a bit wasteful."