changed for() loops to foreach() loops when processing arrays returned by elgg_get_entities* functions