CodeIgniter Forums
CI foreach error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: CI foreach error (/showthread.php?tid=46810)



CI foreach error - El Forum - 11-16-2011

[eluser]Unknown[/eluser]
I get a error when i read Professional CodeIgntier from Wrox press. Check it our the below code
Code:
if(count($navlist)){
echo "<ul>";
foreach($navlist as $key=>$list){
  foreach($list as $topkey=>$toplist){
   echo "<li class='cat'>";
   echo anchor("welcome/cat/$topkey",$toplist['name']);
   echo "</li>\n";
   if(count($toplist['children'])){
    foreach($toplist['children'] as $subkey=>$subname){
     echo "\n<li class='subcat'>";
     echo anchor("welcome/cat/$subkey",$subname);
     echo "</li>";
    }
   }
  }
}
echo "</ul>";
}

When i run i get this error A PHP Error was encountered

Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/navigation.php
Line Number: 5

how can i solve it? :?