note 95632 added to function.glob

From: Date: Wed, 13 Jan 2010 13:01:18 +0000
Subject: note 95632 added to function.glob
Groups: php.notes 
Request: Send a blank email to php-notes+get-164908@lists.php.net to get a copy of this message
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'); ?> ---- Server IP: 217.160.72.57 Probable Submitter: 217.235.228.233 ---- Manual Page -- http://www.php.net/manual/en/function.glob.php Edit -- https://master.php.net/note/edit/95632 Del: integrated -- https://master.php.net/note/delete/95632/integrated Del: useless -- https://master.php.net/note/delete/95632/useless Del: bad code -- https://master.php.net/note/delete/95632/bad+code Del: spam -- https://master.php.net/note/delete/95632/spam Del: non-english -- https://master.php.net/note/delete/95632/non-english Del: in docs -- https://master.php.net/note/delete/95632/in+docs Del: other reasons-- https://master.php.net/note/delete/95632 Reject -- https://master.php.net/note/reject/95632 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164908) next »