com web/php: Have a fixed limit here, and remove endless count()s: images/elephpants.php

From: Date: Fri, 22 Nov 2013 08:35:00 +0000
Subject: com web/php: Have a fixed limit here, and remove endless count()s: images/elephpants.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-17192@lists.php.net to get a copy of this message
Commit: 1d2a2e9ef64493c102768296907b3eaf2860728f Author: Hannes Magnusson <bjori@mongodb.com> Fri, 22 Nov 2013 00:35:00 -0800 Parents: e9bae7527e8de728ea6f598ff51867f2e4bec880 Branches: master Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=1d2a2e9ef64493c102768296907b3eaf2860728f Log: Have a fixed limit here, and remove endless count()s Changed paths: M images/elephpants.php Diff: diff --git a/images/elephpants.php b/images/elephpants.php index 4054853..3375f9d 100644 --- a/images/elephpants.php +++ b/images/elephpants.php @@ -46,10 +46,10 @@ if (!$photos || !is_array($photos)) { // prepare requested number of elephpants at random. shuffle($photos); $elephpants = array(); -foreach ($photos as $photo) { +foreach ($photos as $n => $photo) { // stop when we have the requested number of photos. - if (count($elephpants) == $count) { + if ($n == $count || $n > 20) { break; }

« previous php.webmaster (#17192) next »