Forum Moderators: coopster
foreach($this->details[$code] as $value){
. foreach($value as $option){
. . $spin = $option['option_type'];
. . array_push($totals, $spin);
. } //fe
}// fe
is there anything wrong with that?
the error I am fed is:
Warning: Invalid argument supplied for foreach() in /home/www/site/folder/file.class on line 263
sorry, line 263 is the first line of the inner of the two foreach loops.
I think you are correct in that it is erroring because the input is not an array. Some of the values going to it are and some are not. Is there an easy way to stop the errors?
maybe something along the lines of checking if the input is an array?
foreach($this->details[$code] as $value){
. if(Is_array($value){
. . foreach($value as $option){
. . . $spin = $option['option_type'];
. . . array_push($totals, $spin);
. . } //fe
. } //fi
}// fe
would that work?
the problem line is the one after the new 'if' call.
The problem was that there were 21 items that were not arrays and then one item that was.
the if(is_array$blah) line sorted that by doing nothing for all the 21 that were not arrays but allowing the 22nd to go to the next stage.
Should I be doing it another way?