ADHEAVEN - Natali Ardianto Official

COO tiket.com. Advisor bouncity.com. Advisor golfnesia.com. Co-founded urbanesia.com. Initiator #StartupLokal

January 4, 2012 1:18 pm

Object runs faster than array!

Amazing new finding again. Now take a look at this:

foreach ($query->result_array() as $page):
	$links .= '<a href="'.site_url($page['uri']).'">';
	$links .= ucwords($page['title']).'</a><br />';
endforeach;

compared to this:

foreach ($query->result() as $page):
	$links .= '<a href="'.site_url($page->uri).'">';
	$links .= ucwords($page->title).'</a><br />';
endforeach;

The second one runs faster than the first one. Unbelievable. I think it has got to do with the array hashing. Talking about array hashtable, there’s this new DDoS attack method founded at the late 2011, by using a mere arrays. Here’s the link: http://nikic.github.com/2011/12/28/Supercolliding-a-PHP-array.html