![]() |
Adding additional element to multidimensional array - 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 additional element to multidimensional array (/showthread.php?tid=48218) |
Adding additional element to multidimensional array - El Forum - 01-08-2012 [eluser]mabright[/eluser] In my controller I call my model to get an array of postings (ads posted by users). The array returned looks like what you see below. Before I display the array contents in my view, I want to add an encrypted version of the post ID. I am having issues trying to insert a new array element with the new value. Code: Array I want to add an element called "encrypted_post_id". I have tried the below code but it adds a new element as "0", i.e. the entry in the array as [0] => N1bKWfztfISEx4H2DqmK2JzTkCnuLsQb7w/SJb4PzQzP9puzHiDfIBa9xo/lJ4rhv69kbmXx+8DlZXXahiLWRg==. Code: foreach($content['posts'] as $key => $value) Any help getting the proper element name and value added will be appreciated. |