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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:28:11+00:00 2026-05-31T13:28:11+00:00

Ok, In my Codeigniter project I am passing a multidimensional array to my view.

  • 0

Ok, In my Codeigniter project I am passing a multidimensional array to my view. The issue I am having is access the data in the array. I use print_r and var_dump to see the array and it is being passed correctly to the view but I am having the hardest time access the data within it! I get this error message, “Trying to access parameter of non-object”. Any suggestions?!

Here is the controller: profile.php

    <?php
        class Profile extends CI_Controller {

            public function __construct(){
                parent::__construct();
                $this->load->library('session');

                //Get user data
                $this->load->model('user_model');

            }

            public function user_lookup(){
                //get usering users data
                $email = $this->session->userdata('email');
                //get profile users data
                $username = $this->uri->segment(2,0);

                $user = array(
                            'users' => $this->user_model->getUserData($email),
                            'profile' => $this->user_model->getUserDataWithUsername($username)
                        );

                $this->load->view('profile_view', $user);
            }

        }
    ?>

And here is the view that is recieving the data: profile_view.php

<!DOCTYPE html>
<html>
    <body>
        <?php
             print_r($users[0]);
        ?>
     </body>
 </html>

The output of my print_r statement is:

Array ( [hometown] => Las Vegas [email] => johnmy@gmail.com [university] => UC Berkley [first_name] => Pete [last_name] => Smith [date] => 1992 ) 1

  • 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-05-31T13:28:12+00:00Added an answer on May 31, 2026 at 1:28 pm

    Based on your code:

    $this->load->view('profile_view', $user);
    

    This mean that you supply array $user as view data. Therefore, on view $user is no longer exists.

    You can only use it’s element in view:

    <?php
        echo $hometown;
        echo $email;
    ?>
    

    If you want to use $user array in view, use this view load code in controller:

    $this->load->view('profile_view', array('user' => $user ));
    

    You can read more about Views in CodeIgniter.

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

Sidebar

Related Questions

im having problems starting a codeigniter project, the problem is that when i do
CodeIgniter allows access to POSTed data via: $this->input->post('input_name'); where 'input_name' is the name of
I have a CodeIgniter project. I want to use Memcache, but I don't want
I started to use DOMPDF in my CodeIgniter project to render some information in
I'm working on a codeigniter project and I'm trying to troubleshoot a sql issue.
Im having some trouble getting on with my first codeigniter project, and i have
I'm using this library for Facebook graph API access within my codeigniter project: http://www.haughin.com/code/facebook/
I want to use codeigniter for an ecommerce project I'm working on but I
When creating a CodeIgniter project, what is the best way to handle relations between
I want to add some classes to a CodeIgniter project that aren't models, views,

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.