![]() |
unable to cycle through an array
I have created a counter of two variables for each user and trying to cycle through them so i can get the first and second variables if proving rather hard.
$mainCounters = array('userid' => '', array( 'itemOwnerCommentCount' => 0, 'notItemOwnerCommentCount' => 0 ) ); I tried to use the foreach($newArray = $existingArray) {} but this fails with the following error... Invalid argument supplied for foreach() Code:
foreach($mainCounter as $mainCounters) {How do I correctly access the array data one user at a time ? in case it helps here is what a sample of the array may contain.. Array ( [100] => Array ( [0] => 1 [1] => 0 ) [ABC4EF] => Array ( [0] => 3 [1] => 0 ) [1] => Array ( [0] => 0 [1] => 0 ) [SDF5gH] => Array ( [0] => 0 [1] => 0 ) ) oh I know my userid is not a number, but with good reason, I have had a few ask this in the past ;-) |
ok came back to check if any replies, and just re-read my post, i found the bug... i had
foreach($mainCounter as $mainCounters) { should be.... foreach($mainCounters as $mainCounter) { but still there is a problem... the userid code is not showing... i am trying to cycle through the userid code, and the two array variables, in turn. |
You should nest two foreach.
Like this: PHP Code:
|
| All times are GMT +1. The time now is 09:11 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.