代码改变世界

『PHP』Invalid argument supplied for foreach 解决办法

2013-03-16 09:04  我是文东  阅读(12493)  评论(0编辑  收藏  举报
 1 QUOTE:
 2 foreach($extcredits as $id => $credit) 
 3 {
 4          if($credit['ratio']) 
 5          {
 6                  $exchcredits[$id] = $credit;
 7          }
 8 }
 9 改为
10 
11 QUOTE:
12 if(is_array($extcredits))    //add
13 {                           
14          foreach($extcredits as $id => $credit) 
15          {
16                   if($credit['ratio']) 
17                   {
18                               $exchcredits[$id] = $credit;
19                   }         
20         }
21 }   //add