Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8283023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:35:15+00:00 2026-06-08T10:35:15+00:00

I want to create my own custom config data in the application section of

  • 0

I want to create my own custom config data in the application section of Codeigniter, but was wondering if we can build two dimensional config arrays.

Example of application/config/myconfig.php:

$myconfigarray = array('row1'=> array( 'col1'=>'col1val',
                                       'col2'=>'col2val',
                                       'col3'=>'col3val' ),
                       'row2'=> array( 'col1'=>'col1val',
                                       'col2'=>'col2val',
                                       'col3'=>'col3val' ));

Currently by default at least, Codeigniter only seems to support one dimensional config arrays. How can I use multidimensional arrays?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:35:17+00:00Added an answer on June 8, 2026 at 10:35 am

    You can have configuration arrays in any size shape or form. Getting them to work entirely depends on what you want to do with them, how you’re loading them, and how you’re reading them.

    I think your problem is that you need to rename $myconfigarray to $config:

    http://codeigniter.com/user_guide/libraries/config.html

    Note: If you do create your own config files use the same format as
    the primary one, storing your items in an array called $config

    So for your example, let’s say the file is called myconfig.php:

    $this->load->config('myconfig');
    foreach (config_item('row1') as $k => $v)
    {
        echo $k.' = '.$v;
    }
    

    This would print:

    col1 = col1val
    col2 = col2val
    col3 = col3val
    

    If you need to access a certain index, you’d have to do something like this:

    $item = config_item('row1');
    echo $item['col1']; // col1val
    

    If you happen to be running PHP 5.4 you can access it like so:

    echo config_item('row1')['col1'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi i was just wondering how you can create you own custom file upload
i want to create my own custom admin-url in wordpress... how can i do?
I want to create my own custom graphic based on some parameterized data and
I want to create my own custom collection type. I define my collection as:
How do you create your own custom component for vb.net 2008? I want it
I want to create my own SeekBar because I can't find anything like with
I want to create my own class named Point, but am running into issues
I want to create my own component which consists two other panels. One of
I want to create my own PHP web app where people can signin with
I want to create my own custom control that is basically a TableLayoutPanel with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.