sark9012
sark9012

Reputation: 5747

A for loop not doing as expected

I am running a for loop and attempting to enter data into an array.

When I run the print_r of the array, it's as if the for loop is only running once when it should be running multiple times!

for($i=0; $i<count($count); $i++){
        $currentField = $array[$i];
        $test = "".$field."[".$i."]";
        $this->_postData[$test] = $currentField;
        $this->_currentItems[$i] = $test;
    }

    print_r($this->_currentItems);
    die();

If I echo $count before, it says 3 (for example) but still when I print the array, it only has 1 value! Any ideas?

Thanks.

Upvotes: 0

Views: 50

Answers (2)

zod
zod

Reputation: 12437

i think count is not needed .

try

for($i=0; $i<$count; $i++){

Upvotes: 1

rslite
rslite

Reputation: 84823

Try

for($i=0; $i<$count; $i++)

Upvotes: 3

Related Questions