CodeIgniter – foreach loop

I think there is an error in get_home_sections()

instead of:

        return $get_sections;

you should:

        return $getHomeData

you are returning the last item from the array, that looks like the problem you stated.

Another point i see a little bit confusing is the var you are cummulating html.
$outputData is being reset in each loop, and you are not doing nothing with it. It’s a good idea to initialize it at the begining of the funcion as empty string
$outputData=””;

and in the loop you should do an additive assingment with .=

Leave a Comment