Welcome Guest, Not a member yet? Register   Sign In
[SOLVED]Newbie question: Create a Multi-Dimensional Array
#1

[eluser]Juan Velandia[/eluser]
Hello everyone, I've been dealing with this with little progress, I hope you can help:

I get data with the following model

Code:
function get_section_articles()
    {
        $this->db->select('cms_article.name AS article_name');
        $this->db->select('cms_section.name AS section_name');
        $this->db->from('cms_article');
        $this->db->join('cms_section','cms_article.id_section = cms_section.id_section');
        $this->db->order_by('section_name');
        $query = $this->db->get()->result_array();
        return $query;
    }

and I would like to arrange this data in a multidimensional Array something like this:

Code:
$section = array(
  'Clients'=>array(
    'pepsi',
    'cocacola',
    'sevenup'
  ),
  'Services'=>array(
    'Web Design',
    'Graphic Design',
    'Data Migration'
  ),
  'Techonologies'=>array(
    'codeigniter',
    'postgresql',
    'ubuntu'
  )
);

I have a database where, 'Clients', 'Services','Techonologies' are in the section Table each one with it's id_section, and, 'pepsi', 'cocacola', 'sevenup', Web Design','Graphic Design', 'Data Migration','codeigniter','postgresql', 'ubuntu' are in the article table wich have a id_section column.

I hope I've been clear, thanks in advance!


Messages In This Thread
[SOLVED]Newbie question: Create a Multi-Dimensional Array - by El Forum - 11-10-2010, 09:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB