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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:50:34+00:00 2026-05-22T11:50:34+00:00

is there are in build php function or I have to write my own

  • 0

is there are in build php function or I have to write my own one to merge two multidimensional arrays like that

$list1 = array("school1" => array('string1','string2'));

$list2 = array("school1" => array('string1','string3'),
               "school2" => array('string1','string4','string5')
         );

into array where nothing will be overwritten or omitted. I want to have only unique values in the the ‘second array’. Meaning that array school1 will contain string string1 once only

Array ( [school1] => Array ( [0] => string3 [1] => string2 [2] => string1 ) 
        [school2] => Array ( [0] => string5 [1] => string4 [2] => string1 ) ) 

ideal would be if I can have the second array = string1, string2 …. sorted desc

  • 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-22T11:50:34+00:00Added an answer on May 22, 2026 at 11:50 am

    my solution

    function merge_db_lists ($list1, $list2) {
      $final_array = array();
      $final_array = go_through_list($list1, $final_array);
      $final_array = go_through_list($list2, $final_array);
      return $final_array;
    }   
    
    function go_through_list($list,$output){
      foreach (array_keys($list) as $key){
        if (array_key_exists($key, $output)){
          foreach ($list[$key] as $item ){
            $output[$key][] = $item;
          }  
          arsort($output[$key]);
        }
        else{
          $output[$key] = $list[$key];
        }  
      }
      return $output;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a custom function to insert/edit/delete records from a database
I am attempting to write a recursive descent parser in PHP for the following
I have a page (parent) that when a button (with .click funciton) is clicked
I have a website that contains a number of projects and each project is
I have a php script to retrieve data from a MysQL databse following an
I have a simple admin I'm creating for a client using PHP and Mysql.
I'm looking to create a sort of HashMap class in PHP. For the sake
I'm starting to build a little PDO wrapper I will be using for my
I am not sure if I have totally missed something here so I am
I'm searching for a way to use named arguments for sprintf or printf .

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.