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

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

Browse More Popular Posts

Leave a Comment