note 95632 deleted from function.glob by danbrown

From: Date: Wed, 13 Jan 2010 15:50:30 +0000
Subject: note 95632 deleted from function.glob by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164916@lists.php.net to get a copy of this message
Note Submitter: mail2lx {at} gmx ]dot[ net ---- Re: tailinchu[at]gmail[dot]com This is not a good idea, because this simple line causes two filesystem operations, where only one would be required. This is not only bad style, but on a directory with many files, you will definitely feel the delay. If you want to be sure to work on an array, you better use typecasting, rather than a ternary operator. This has better performance, and is even less code: <?php $files = (array)glob('*.txt'); ?>

« previous php.notes (#164916) next »