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

The Archive Base Latest Questions

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

This is my code, in this code, I am reading an existing array through

  • 0

This is my code, in this code, I am reading an existing array through a function read_from_json, which convert JSON to array, now from remote data I am getting new data so I have to append those data in my existing array without overwriting the whole array. Like if I am getting an id, it searches using the in_array function, if it is not found then sending a message to it, and then append the only specific entry to existing array. There is a problem due to foreach iteration so it overwrites all array, what else can I do. Please have a look at this code:

$read_data = $this->read_from_json( 'xyz.json' );

foreach ( $projects_id_tickcamp as $tick_id => $base_id ) {

            if ( !$this->in_array( $base_id['base_id'], $read_data ) ) {

                echo '<b>do post message function for ' . $tick_id . ' ' . $base_id['base_id'] . '</b><br />';

                $i = count( $read_data );

                while ( $i >= count( $base_id['base_id'] ) ) {

                    echo 'post message start' .'<br />';
                    $i++;
                    break;
                    $projects_id_tickcamp[$tick_id]['message_id'] = 1;

                }

                //echo 'posted message id of ' . $base_id['basecamp_id'] . '<br />';
            } else {
                echo 'do nothing' . '<br />';
                //return false;
            }
        }

        //echo 'write data if id similar' . '<br />';
        $this->write_to_json( 'xyz.json', $projects_id_tickcamp );
        return $projects_id_tick;

The output of the above code looks like:

Array
(
    [125434] => Array
        (
            [base_id] => 1306755
        )

    [127354] => Array
        (
            [base_id] => 1287834
        )

)

if a new id fetch from remote then id writes only in last place of array.

  • 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-13T02:09:43+00:00Added an answer on June 13, 2026 at 2:09 am

    You have a few options:

    • array_push()
    • array_merge( $curr_array, $new_array )
    • $array[] = $newValue

    Good luck!

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

Sidebar

Related Questions

Reading existing code at work, I wondered how come this could work. I have
Note: This code actually codes from a tutorial book I'm reading at the moment,
I am reading existing code. I noticed that there are many data object files
I'm reading this code sample : And since I don't know C#, I decided
i was reading this code, where setRegions is called after RootViewController is released :
i am reading an excel file using this code i found over the net:
I am reading On lisp and encountered this code (I simplified it a bit).
I was reading a blog where the writer said this Code doesn’t exist unless
I'm reading Programming Perl , and I found this code snippet: sub new {
While I'm reading boost/shared_ptr.hpp, i saw this code: // generated copy constructor, destructor are

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.