bazianm Posted December 28, 2014 Share Posted December 28, 2014 I have a simple foreach loop. The array has four rows in it. Really simple. I have confirmed the data in the array with var_dump. For some reason I cannot fathom, the loop is only processing rows 0 and 2 and is not processing 1 and 3. Here's the code snippet: <?php foreach ($postCals as $key=>$cal){ var_dump($postCals, $cal, $key); echo '<td style="text-align:right;>' . $cal . "</td>"; } ?> $postCals has precisely 4 values. Here's the output from this part of the code (in terms of the var_dumps). array (size=4)0 => string '2.00000' (length=7)1 => string '2.00000' (length=7)2 => string '3.20000' (length=7)3 => string '4.00000' (length=7)string '2.00000' (length=7)int 0array (size=4)0 => string '2.00000' (length=7)1 => string '2.00000' (length=7)2 => string '3.20000' (length=7)3 => string '4.00000' (length=7)string '3.20000' (length=7)int 2 That's it. I two other foreach loops identical to this and they run fine! Any ideas? (misc info: php: 5.4.7 running on XAMPP/Windows ) Quote Link to comment https://forums.phpfreaks.com/topic/293453-foreach-skipping-rows-in-array/ Share on other sites More sharing options...
NotionCommotion Posted December 28, 2014 Share Posted December 28, 2014 (edited) Good for using var_dump()! Now, look at your HTML. It is always nice that when you witness something impossible, it is not happening Your missing a quote. Edited December 28, 2014 by NotionCommotion Quote Link to comment https://forums.phpfreaks.com/topic/293453-foreach-skipping-rows-in-array/#findComment-1500963 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.