Re: BP for Looping through an Array
| From: | Daniel Brown | Date: | Fri, 28 Oct 2011 19:32:01 +0000 |
| Subject: | Re: BP for Looping through an Array | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-315513@lists.php.net to get a copy of this message | ||
On Fri, Oct 28, 2011 at 14:18, Jim Long <php@umpquanet.com> wrote:
>
> If you are certain that your array is consecutively indexed from
> 0, you can shave two lines off your code with:
>
> $allFiles = array("coffee.jpg", "tea.jpg",
> "milk.jpg");
> foreach ($allFiles as $key => $currFile) {
> doThisWith($currFile);
> doThatWith($key+1);
> }
See also: http://php.net/array_walk
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/