[eluser]SardiorDragon[/eluser]
[quote author="vitoco" date="1246253645"][quote author="Dam1an" date="1246157794"]get_filenames returns a boolean (FALSE) if the opendir command fails, and a boolean is not valid for a foreach loop
To see if this is the case, to a var_dump/print_r on what it returns[/quote]
true , so you could do this in the view to see if the function returns a FALSE or an array
Code:
<?
if( is_array( $images ) )
{
//<pre> tag it's only to make the array structure more readeable
echo '<pre>'.print_r( $images , true ) .'</pre>';
}
else
{
echo 'NO IMAGES ( FALSE ) ';
}
?>
Saludos.[/quote]
This can be done in the view but as a personal preference I would rather check the array in the controller and if it is FALSE then pass an empty array to the view. This way the foreach will still find an array but will not actually do anything because there is no data to handle.