user001
user001

Reputation: 471

Invalid argument supplied for foreach

I have got this warning, have someone an idea:

warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\testplanning\modules\planning\planning.module on line 425.

The code where he the fall is:

foreach($stap3[2] as $key => $value) {
    $waardeSoortStage[$key] = $value;
}

Upvotes: 0

Views: 1668

Answers (3)

osm
osm

Reputation: 4218

$stap3[2] is not an array or an empty array.

You can check $stap3[2] with is_array($stap3[2]) If is really array it returns true.

Also you can debug it with var_dump($stap3[2])

Upvotes: 1

Tokk
Tokk

Reputation: 4502

I think you wanted to do so:

foreach($stap3 as $key => $value) {
    $waardeSoortStage[$key] = $value;
}

because I think $stap3 is your array,$stab3[2] might only be one member of it.

Upvotes: 1

Michiel Pater
Michiel Pater

Reputation: 23033

Probably the variable $stap3[2] is not an array.

Upvotes: 3

Related Questions