Page 1 of 1

Array_fill

Posted: Mon May 19, 2008 9:12 pm
by baileylo
Does anybody know how the array_fill() algorithm works, on my computer it runs faster than array pad as well as an iterative approach. I was wondering if anybody knew how it worked

Re: Array_fill

Posted: Wed May 21, 2008 5:08 am
by Maugrim_The_Reaper
You best bet is to locate it's C source in the PHP CVS repository. I haven't looked at it so I couldn't say.

Re: Array_fill

Posted: Thu May 22, 2008 9:35 pm
by Ambush Commander
http://cvs.php.net/viewvc.cgi/php-src/e ... iew=markup

It's not surprising that array_fill is much faster than the iterative approach or array_pad. array_fill uses PHP's internal C functions for manipulating arrays, bypassing the need to execute quite a few opcodes.