Re: isset

From: Date: Tue, 17 Apr 2007 01:06:01 +0000
Subject: Re: isset
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-253093@lists.php.net to get a copy of this message
On Mon, 2007-04-16 at 19:05 -0500, Richard Lynch wrote: > On Mon, April 16, 2007 6:10 pm, Jochem Maas wrote: > > if I know it's an array I'll definitely use empty() over count() .... > > count() needs to actually count the items where as empty() can return > > false > > as soon as it finds a singel element ... maybe I'm mistaken - if so > > please > > put me right. > > You're wrong. > > The count is maintained internally as items are added/removed, and it > is an O(1) operation for PHP to "count" the array, as it already knows > the answer and just returns it. Fastest way to check if an array has elements... <?php if( $array ) { } ?> Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.general (#253093) next »