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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:14:03+00:00 2026-05-13T07:14:03+00:00

Quotes object: Array ( [0] => Array ( [sitecaptions] => Array ( [id] =>

  • 0

Quotes object:

Array
(
    [0] => Array
        (
            [sitecaptions] => Array
                (
                    [id] => 2
                     => Great camera deals!
                    [linkurl] => http://www.99hotdeals.com/cat/Cameras
and Camcorders
                )

        )

)

The Posts Object:

Array
(
[0] => Array
        (
            [Post] => Array
                (
                    [id] => 2797
                    [post_title] => xx1
                    [item_desc] => xx desc
                    [dateadded] => 2009-12-22 11:10:15
                )
            [Category] => Array
                (
                    [0] => Array
                        (
                            [id] => 99
                            [name] => Others
                        )

                )
       )
[1] => Array
        (
            [Post] => Array
                (
                    [id] => 2798
                    [post_title] => xx2
                    [item_desc] => xx2 desc
                    [dateadded] => 2009-12-22 11:10:45
                )
            [Category] => Array
                (
                    [0] => Array
                        (
                            [id] => 99
                            [name] => Others
                        )

                )
       )
)

As you can see, the Posts Object contains two elements, [Post] and
[Category] for each record [0],[1] etc. I want to insert the
[sitecaptions] element into that Posts Object so that in effect it
looks like:

Array
(
[0] => Array
        (
            [Post] => Array
                (
                    [id] => 2797
                    [post_title] => xx1
                    [item_desc] => xx desc
                    [dateadded] => 2009-12-22 11:10:15
                )
            [Category] => Array
                (
                    [0] => Array
                        (
                            [id] => 99
                            [name] => Others
                        )

                )
            [sitecaptions] => Array
                (
                    [id] => 2
                     => Great camera deals!
                    [linkurl] => http://www.99hotdeals.com/cat/Cameras
and Camcorders
                )
       )
)

How do I combine two objects like that? Or how do I insert elements
into an existing object? Hope I’m clear about what I’m asking. Thanks
for your time…

  • 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-13T07:14:03+00:00Added an answer on May 13, 2026 at 7:14 am

    lets call these objects $Quotes and $Posts respectively.

    Quotes object:

    Array (
        [0] => Array ( 
            [sitecaptions] => Array (
                [id] => 2 
                 => Great camera deals! 
                [linkurl] => http://www.99hotdeals.com/cat/Cameras and Camcorders )
                )
            )
        )
    

    The Posts Object:

    Array ( 
        [0] => Array (
            [Post] => Array (
                [id] => 2797
                [post_title] => xx1
                [item_desc] => xx desc
                [dateadded] => 2009-12-22 11:10:15 
            )
            [Category] => Array (
                [0] => Array (
                    [id] => 99
                    [name] => Others
                )
            )
        )
        [1] => Array (
            [Post] => Array (
                [id] => 2798 
                [post_title] => xx2 
                [item_desc] => xx2 desc 
                [dateadded] => 2009-12-22 11:10:45
             )
             [Category] => Array (
                [0] => Array (
                    [id] => 99 
                    [name] => Others 
                )
            )
       )
    )
    

    do you want the [sitecaptions] from the $quotes to be in both of your $posts elements? or just the one with the same key?

    as to say if you have just $quotes[0] only $posts[0] will be affected. OR both $posts[0] and $posts[1] will be affected.

    if you want $quotes[0] to be in both $post elements you can do this:

    foreach ($posts as $key=>$post) {
        $posts[$key]['sitecaptions'] = $quotes[0]['sitecaptions'];
    }
    

    if you want only the elements from $quotes that have the same index as the elements in $posts you can do this:

    $posts = array_merge_recursive($posts,$quotes);
    

    doing this second one would have $posts[1] being without a [‘sitecaptions’] element.
    end result:

    Array (
        [0] => Array ( 
            [Post] => Array ( 
                [id] => 2797 
                [post_title] => xx1 
                [item_desc] => xx desc 
                [dateadded] => 2009-12-22 11:10:15 
            ) 
            [Category] => Array ( 
                [0] => Array ( 
                    [id] => 99 
                    [name] => Others 
                )
            )
            [sitecaptions] => Array (
                [id] => 2
                 => Great camera deals!
                [linkurl] => http://www.99hotdeals.com/cat/Cameras and Camcorders 
            )
        )
    )
    

    Hope it helps!

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

Sidebar

Related Questions

I am playing with a basic implementation of the Query Object pattern (in quotes
I have an object array that is being passed and then split up into
The JSON spec says that JSON is an object or an array. In the
Two quotes: All of the remaining messages in the protocol take the form of
Quasi-quotes allow generating AST code during compilations, but it inserts generated code at the
I have to remove quotes from a relatively large text file. I have looked
I say branch in quotes because I mean branch in the data-structure, graph topology
PHP uses magic quotes by default but has gotten a lot of flak for
I'd like double quotes to appear within the following string so it looks like:
Should I encode quotes (such as and ' -> ” and ’ ) in

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.