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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:08:17+00:00 2026-05-25T06:08:17+00:00

I have been able to add 2 arrays together in my script. The problem

  • 0

I have been able to add 2 arrays together in my script. The problem is, as seen below, the second item in the array is name [0] I need this to say [user].

    [0] => Array
    (
        [id] => 1
        [0] => Array
            (
                [id] => 1
                [first_name] => Cody
                [last_name] => Robertson
                [email] => codyrob@me.com
                [password] => 
                [age] => 16
                [city] => Commerce Township
                [country] => United States Of America
                [friends] => 
                [avatar] => http://blazebyte.org/community/index.php?action=dlattach;attach=4415;type=avatar
                [register_date] => 2011-09-03
                [laststatus_date] => 0000-00-00
            )

        [status] => This is my first status. Will be pulled from API. :D
        [date] => 2011-09-02 23:26:09
    )

And here is my PHP code.

    public function all_get()
{
    $feed = array();
    $data = array();

    $query = $this->db->query('SELECT * FROM `statuses`');

    if($query->num_rows() > 0)
    {
        $statuses = $query->result_array();

        foreach($statuses as $status)
        {
            $i = 0;

            $query = $this->db->query('SELECT * FROM `members` WHERE id='. $status['uid']);

            if($query->num_rows() > 0)
            {
                $user = $query->result_array();

                $first = array_slice($status, 0, 1, true);
                $secnd = array_slice($status, 2, null, true);

                foreach($user as $info => $value)
                {
                    $data[$info] = $value;
                }

                $feed[] = array_merge( (array) $first, (array) $data, (array) $secnd);
            }

        }   
    }

    return $feed;
}
  • 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-25T06:08:17+00:00Added an answer on May 25, 2026 at 6:08 am

    Quick fix would be: (insert this just before return)

    foreach($feed as &$f) {
      $f['user']=$f[0];
      unset($f[0]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to add an object as an NSMutableDictionary to my array,
I have been able to zip the contents of my folder. But I would
I have been able to copy the raw data from an otherwise inaccessible USB
I have been able to create ASPX pages without the code behind, but I
I have been able to design my layout so that it has 2 columns
The best that I have been able to come up with is: strlen(preg_replace('/^([\\*]*)\s(.+)/',$1,$line)); ^^That
Hi I have been able to extract a VARCHAR to a date using string_to_date
It seems obvious that some people have been able to figure out how to
My knowledge of xml and php is somewhat basic but have been able to
I'm having problems refreshing .Net 2.0 with IIS 6. I have been able to

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.