Adding column to an array and not appending - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Adding column to an array and not appending (/showthread.php?tid=54592) |
Adding column to an array and not appending - El Forum - 09-15-2012 [eluser]agammill[/eluser] I have an array where I need one column in the array formatted in a certain way. So I successfully created a second array, based on a column in the first array but I’m having trouble adding the new column back into the first array. merge_array and push array are placing the data AFTER the first array and not as another column in the first array. Code: $matches = $this->my_model->getRandom(); //this is the first array I’d like the new column to have the key name 'tag_display' but when I add it to the array like this: Code: foreach ($matches as $tag){ but this only displays the last element. |