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 8775227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:45:09+00:00 2026-06-13T18:45:09+00:00

I have a simple question. Let me explain We use this to pass data

  • 0

I have a simple question. Let me explain
We use this to pass data from controller to view

function index(){

    $data['title'] = 'This is title';
    $data['message'] = 'This is message';
    $this->load->view('test',$data);
}

Here we are using Associative Array to pass data
And now this function again and use indexed array instead of Associative Array

function index(){

    $data[] = 'This is title';
    $data[] = 'This is message';
    $this->load->view('test',$data);
}   

And now in View this does not work.

echo $data[0];
echo '<br>';
echo $data[1];

i only want to know if why this does not work. And in the user guide i never read that associative array is necessary.

  • 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-13T18:45:10+00:00Added an answer on June 13, 2026 at 6:45 pm

    The view data are converted into variables when parsed. A similar result of what extract() function of PHP gives. For example:

    $data['title'] = 'This is the title';
    

    will be accessible directly as $title not $data['title']. In fact, if you look at the sources, you will find it does uses extract() and similar conversion happens on your case to, but since variable $0 and $1 are invalid so they are not available.

    Stick to string indexing. If that is not an option, then you might want to prefix something before the texts like:

    $data['d0'] = 'This is the title';
    

    Read the manual here its quoted. However, you can pass an array instead of a string and giving the exact result of what you want.

    $data['data'] = array('This is the title', 'This is the description');
    

    Now, this you will be access using $data[0] and $data[1].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe my question this time is simple. Let say I have a webpage,
i have simple question, let's say i have input like this: <input name=somename type=checkbox
I have a simple question: Let's supose i have the next span: <span class=data
I have a simple question. Let's say I have a .Net solution, with different
i have a simple question: i have this var: $v = 24000,1500,1500,1500,1500,1500,; i would
i have a simple question, there is a function with parameter emp_id that opens
I'm a beginner in jQuery area and I have simple question like this :
I have this question. But it will be difficult for me to explain as
Let's try to explain the title of my question to be the more concise
I have a design question: let me expalin in simple example: Public class A()

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.