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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:21:46+00:00 2026-06-03T05:21:46+00:00

I have one master array and multi slave arrays and i need function that

  • 0

I have one master array and multi slave arrays and i need function that replace values on same array keys.

example:

master array:

$master = array(**"a"=>"master a"**,**"b"=>"master b"** "c"=>"master c");

slave arrays:

$slave_a = array("s1"=>array(**"a"=>"slave a"**,"f"=>"slave f"));
$slave_b = array("s2"=>"slave" **"b"="slave b"**);

I need function to filter slave arrays to look like:

$slave_a to be array("s1"=>array(**"a"=>"master a"**,"f"=>"slave f"));
$slave_b to be array("s2"=>"slave" **"b"="master b"**);

Тhanks in advance and sorry for my poor English

  • 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-03T05:21:47+00:00Added an answer on June 3, 2026 at 5:21 am

    OK, so after parsing the ini files using parse_ini_file You should end up with arrays similar to this (when using process sections TRUE):

    $first_ini = array(
        'MAIN' => array(
            'lib' => 'lib_folder',
            'bin' => 'bin_folder',
            'usr' => 'usr_folder',
            'etc' => 'etc_folder'
        )
    );
    
    $second_ini = array(
        'alib' => 1,
        'abin' => 0,
        'ausr_other' => 'usr/tree'
    );
    
    $master_ini = array(
        'lib' => 'lib_other',
        'abin' => 1
    );
    

    Then You can use this simple function (not tested):

    function combine_master_with_slave($master, $slave) {
        foreach($slave as $key => $val) { // we will loop through slave array
            if(is_array($val)) { // if the value is an array use recursion
                $slave[$key] = combine_master_with_slave($master, $val);
            }
            if(isset($master[$key])) { // if master array contains the same key as a slave array, replace it's value by the master's one
                $slave[$key] = $master[$key];
            }
        }
        return $slave; // finaly return the processed slave array
    }
    

    But I am really not sure whether this will work, maybe it will need some slight modifications…

    Also You will have to call this function so many times as many slave arrays You have, or in other words, You will have to call this function for each slave array.

    This should work for any sub-array level, even it would be [ [ [ [ [ [][][][] ] ] ] ] ].

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

Sidebar

Related Questions

I have an array. One of the values in that array responses[1] is an
I have two pages that inherit from one master page, First.aspx or second.aspx. Navigation
I have a heavily parallelized build across 45 slaves (one master that just handles
I have an array of arrays that is currently printing each object in the
Here's one that's sure to be fun for someone. So I have an array
Ok so I have an array that looks like this. [Enter Sandman, One, Nothing
I have one master page which applies to all pages in this website. On
I have one master report with sub report. in master report display single value
I am working with an ASP.NET MVC application. I have one master page having
I have a SplitViewController which has two UITableViewControllers - one master/root one detail. Everything

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.