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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:31:46+00:00 2026-05-19T02:31:46+00:00

Continue from this topic link text Hi guys. I am using codeigniter and want

  • 0

Continue from this topic link text

Hi guys. I am using codeigniter and want to store data in the session. I have this array

array(4) { 
[0]=> array(2) { ["DESC"]=> string(1) "A" ["SUBFUNCTION_ID"]=> string(3) "904" } 
[1]=> array(2) { ["DESC"]=> string(1) "B" ["SUBFUNCTION_ID"]=> string(3) "903" } 
[2]=> array(2) { ["DESC"]=> string(1) "C" ["SUBFUNCTION_ID"]=> string(3) "902" } 
[3]=> array(2) { ["DESC"]=> string(1) "D" ["SUBFUNCTION_ID"]=> string(3) "901" } 
} 

And this is the array to store the session data

$data = array(
'username' => $this->input->post('username'),
'userid' => $query->USER_ID,    
'role' => $query->ROLE_ID,    
'is_logged_in' => true

);

How can i manipulate the first array and then append the data into the second array? I want it to become something like this

$data = array(
'username' => $this->input->post('username'),
'userid' => $query->USER_ID,    
'role' => $query->ROLE_ID,    
'is_logged_in' => true,
'A' => 904,
'B' => 903,
'C' => 902,
'D' => 901

);

Thanks in advance

  • 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-19T02:31:47+00:00Added an answer on May 19, 2026 at 2:31 am

    It sounds like you have your session data in the form of $foo and starting data $data

    $foo = array (
        array('DESC'=>'A', 'SUBFUNCTION_ID'=>904),
        array('DESC'=>'B', 'SUBFUNCTION_ID'=>903),
        array('DESC'=>'C', 'SUBFUNCTION_ID'=>902),
        array('DESC'=>'D', 'SUBFUNCTION_ID'=>901),
    );
    
    $data = array(
        'username' => $this->input->post('username'),
        'userid' => $query->USER_ID,    
        'role' => $query->ROLE_ID,    
        'is_logged_in' => true
    );
    

    To merge in the data from $foo into $data as you requested, loop over all values in $foo and then append them to $data

    foreach($foo as $bar) {
        $data[$bar['DESC']] = $bar['SUBFUNCTION_ID'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that I'd like to continue using, but it looks like
I know that there have been plenty of topics describing this topic but I
It seems that Groovy does not support break and continue from within a closure.
I continue to get this error: Object '%s' cannot be renamed because the object
Should developers avoid using continue in C# or its equivalent in other languages to
I have to continue to support VB6 applications. I've got both VB6 (Visual Studio
Is there a way to read a file's data but continue reading the data
I want to draw route in map, for this I am storing latitude and
When should I continue to make derived classes, and when should I just add
As I continue my quest of learning functional programming, I've come to wonder if

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.