Array_fill

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
baileylo
Forum Newbie
Posts: 13
Joined: Sun Sep 30, 2007 12:48 am

Array_fill

Post 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
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Re: Array_fill

Post 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.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Array_fill

Post 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.
Post Reply