Welcome Guest, Not a member yet? Register   Sign In
Assigning new elements to an associated array witin a foreach
#1

[eluser]Tim Reynolds[/eluser]
I am having problems with assigning a new element to an array during a foreach loop.

While echoing the alias of the array position inside the foreach the new element seems to have been created and populated correctly. When you print the array outside the loop it does not contain the new fields. The code is part of a big method but the snippet is included,

Code:
$this->CI->template['navigation'] = $this->CI->page->getNav(0);
foreach($this->CI->template['navigation'] as $nav){
$subnav = $this->CI->page->getSubNav($nav['path']);
$nav['subnav'] = $subnav;
}

Is this the correct method of performing this operation? I can post more code/debug info if needed.

Thanks


Messages In This Thread
Assigning new elements to an associated array witin a foreach - by El Forum - 10-19-2009, 05:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB