Monthly Archives: September 2008

Ubuntu Vs. Broadcom

I have a Compaq Presario F500 laptop, which comes with a built-in Broadcom wireless network adapter. Vista Home Premium came pre-installed, but the system only has 1Gb of RAM, which is the it’s maximum.

Vista is so power-hungry that things were never going to go well. The straw which broke the camel’s back came one Sunday afternoon when I was surfing the web while listening to music on WMP. I navigated to a site with an embedded flash video and the system froze, completely. I rebooted and tried again but got the same problem, the system was totally maxing out. It’s worth mentioning that I already had Aero and all the fancy, (read sparkly; pointless), effects turned off. I came to the conclusion that Vista had to go.

The system is distinctly mid-range and I only use it for surfing the web, chatting online and email so I decided that Linux in anUbuntu flavour was the way to go. The software and feature list which comes with this distribution is pretty good and installing was a cinch so I was really happy… for a few minutes, at least!

As it turns out, Linux hates the Broadcom wireless adapter in my laptop. It took me hours of Google searching, driver installations, plenty of swearing and a complete re-install to get it working. Even now, it’s buggy to say the least. I really think it’s issues such as this which put people off using Linux over other operating systems, which is a shame.

Anyway, the solution to this too-common problem can be found here.

Share Button

Array Looping in PHP

I remember back when I as learning PHP I had to write a directory “spider” function to list the contents of a directory. (Including sub-directories).

The approach I took involved reading the initial contents of the base directory into an array. The plan was then to loop through the array adding any sub-directories, (and their files), recursively.

In my naivety, I assumed that I could do something similar to:

foreach($results as $result){
	if(is_dir($result)){
		//Add directory's contents...
	}
}

But, I quickly learned that the foreach construct works on a copy of the array, so adding to it in a recursive fashion is not possible. Bum.
There’s a fairly simple solution to the problem though:

for($i=0; ; $i++){ //Infinite loop
	if($i < count($results)){
		$result = $results[$i];
		if(is_dir($result)){
			//Add directory's contents...
		}
	}
	else break; //Nothing left to process, so break out of the loop
}
Share Button