4 times in 4 times (in this example, but potentially more than 4) I copy the values in $ foo and $ Crap like this:
$ foo [0] = $ bar [0]; $ Ef [1] = $ bar [2]; $ Bl [0] = $ bar [1]; $ Blah [1] = $ bar [3]; So, the lines of $ bar will also be copied into $ foo [i], and weird rows will be copied to $ blah [i].
I tried with:
for ($ i = 0; $ i & lt; 2; $ i ++) {for ($ j = 0 ; $ J & lt; 4; $ j ++) {if ($ j% 2 == 0) {$ foo [$ i] = $ bar [$ j]; // EVEN} and {$ blah [$ i] = $ bar [$ j]; // ODD}}} However if I show the output of $ foo and $ blah, $ foo is equal to [0] $ foo [1], and $ blah [0] For example: Source:
$ bar [0]: 27.8 $ bar [1]: $ blah is equal to [1], while they should be placed in different values. Napoli-Posilipo $ bar [2]: $ 29 times [3]: studio San Paolo di Napoli, Napoli wrong result of loop:
$ Foo [0] = 29 (this should be 27.8) $ foo [1] = $ 29 Blah [0] = stadio san paolo di Napoli, Napoli (this should be Napoli-poisilpo) $ Blah [1] = Stadium San Paolo Di Napoli, Napoli Any hint? Thank you
You made it complicated, something simple should be done like this: < Pre> foreach ($ bar = $ k = & gt; $ v) {if ($ k% 2 == 0) {$ foo [] = $ v; // EVEN} and {$ blah [] = $ v; // ODD}}
Comments
Post a Comment