Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14803
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
| Newsgroups | comp.lang.php |
| Subject | Re: Running same code multiple times, while only changing two parameters |
| Date | Sun, 04 Jan 2015 23:21:34 +0100 |
| Organization | solani.org |
| Lines | 41 |
| Message-ID | <m8cedb$30c$2@solani.org> (permalink) |
| References | <7a2f6bc8-1f1d-4e65-98ea-f9d4f80e8c0b@googlegroups.com> <874ms6z2jp.fsf@bsb.me.uk> <8e0a3f82-6daa-4f62-9f1b-b89918b0417c@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | solani.org 1420410091 3084 eJwFwYERACEIA7CVnoPWMo7id/8RTJAMziqCBcNXiKM9v7bqS2EahGPNKYvcdibaQt/K5gMcCRDN (4 Jan 2015 22:21:31 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Sun, 4 Jan 2015 22:21:31 +0000 (UTC) |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
| X-User-ID | eJwFwQkBwDAIA0BLHZAAcloe/xJ2B+XHciNoWGxGWoXImSsyia639BuRlGIXXQNjKu1zHvMHE3wQww== |
| In-Reply-To | <8e0a3f82-6daa-4f62-9f1b-b89918b0417c@googlegroups.com> |
| Cancel-Lock | sha1:5kt4fpk6AwBZfAKy20WAL9/xUqo= |
| X-NNTP-Posting-Host | eJwFwYEBgDAIA7CXwLUMzlGg/59gwhMefREMUFQnrbPcYYtRMtyAc3EWNeV4Yx+rz1w7Jv3/ZBBy |
| Xref | csiph.com comp.lang.php:14803 |
Show key headers only | View raw
semeon.risom@gmail.com wrote:
> Example:
> Frequency
> Image 1) 50
> Image 2) 65
> Image 3) 97
> ...
>
> Orientation
> Image 1) 65
> Image 2) 45
> Image 3) 66
> ...
>
> What's happening (Frequency, Orientation)
> [9 "images"]
That is because you are nesting two loops, e.g.
foreach (array(50, 65, 97) as $freq) {
foreach (array(65, 45, 66) as $orient) {
// do something with $freq and $orient here
}
}
> What I want (Frequency, Orientation)
> [3 "images"]
Then you should use only one loop, e.g.
$pairs = array(array(50, 65), array(65, 45), array(97, 66));
foreach ($pairs as $pair) {
list($freq, $orient) = explode($pair);
// do something with $freq and $orient here
}
--
Christoph M. Becker
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Running same code multiple times, while only changing two parameters semeon.risom@gmail.com - 2015-01-04 08:47 -0800
Re: Running same code multiple times, while only changing two parameters "J.O. Aho" <user@example.net> - 2015-01-04 19:13 +0100
Re: Running same code multiple times, while only changing two parameters semeon.risom@gmail.com - 2015-01-04 13:18 -0800
Re: Running same code multiple times, while only changing two parameters Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-01-04 20:58 +0000
Re: Running same code multiple times, while only changing two parameters semeon.risom@gmail.com - 2015-01-04 13:15 -0800
Re: Running same code multiple times, while only changing two parameters "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-04 23:21 +0100
Re: Running same code multiple times, while only changing two parameters Richard Damon <Richard@Damon-Family.org> - 2015-01-04 16:21 -0500
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-04 22:22 +0000
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-04 23:10 +0000
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-04 23:14 +0000
Re: Running same code multiple times, while only changing two parameters semeon.risom@gmail.com - 2015-01-05 12:47 -0800
Re: Running same code multiple times, while only changing two parameters semeon.risom@gmail.com - 2015-01-05 12:50 -0800
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-06 00:42 +0000
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-06 18:59 +0000
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-06 00:28 +0000
csiph-web