Welcome Guest, Not a member yet? Register   Sign In
passing array to views
#6

[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 ) ';
    }
?&gt;

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.


Messages In This Thread
passing array to views - by El Forum - 06-27-2009, 03:44 PM
passing array to views - by El Forum - 06-27-2009, 03:56 PM
passing array to views - by El Forum - 06-27-2009, 03:58 PM
passing array to views - by El Forum - 06-27-2009, 09:40 PM
passing array to views - by El Forum - 06-28-2009, 06:34 PM
passing array to views - by El Forum - 06-29-2009, 06:48 AM
passing array to views - by El Forum - 06-29-2009, 09:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB