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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:41:06+00:00 2026-06-18T11:41:06+00:00

how do i combine these arrays and use a specific value as key/index? here’s

  • 0

how do i combine these arrays and use a specific value as key/index?
here’s sample array i’m playing with:

Array  
(  
    [0]=>john   
    [1]=>peter  
)  

Array  
(  
    [dept]=>engineering  
    [sub]=>trigonometry  
    [time]=>08:00  
 )  

what i want to achieved is like this:

Array  
(  
    [john]=>john  
    [dept]=>engineering  
    [sub]=>trigonometry  
    [time]=>08:00    

    [peter]=>peter
    [dept]=>engineering  
    [sub]=>trigonometry  
    [time]=>08:00   
)  

thanks in advance guys, hope u can help me with this. appreciate it.

  • 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-18T11:41:07+00:00Added an answer on June 18, 2026 at 11:41 am

    I think you may want to associate the value of the first array with the values of the second array.

    $finalArray = array();
    foreach($firstArray as $name) {
        $finalArray[$name] = $secondArray;
    }
    print_r($finalArray);
    

    You will get :

    Array
    (
        [john] => Array
                  (
                      [dept]=>engineering  
                      [sub]=>trigonometry  
                      [time]=>08:00  
                  )
        [peter] => Array
                  (
                      [dept]=>engineering  
                      [sub]=>trigonometry  
                      [time]=>08:00  
                  )
    )
    

    Does this help you?

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

Sidebar

Related Questions

status_name=Array(a,b,c,b,e,f); status_id=Array( 1, 2, 3, 4, 5, 6); How to combine these two arrays
I would like to use parallel processing for taking array statistics for large arrays
Can I combine these 2 SQL statements? Currently running 2 queries. Trying to tighten
How do I combine these two select statements into one query: SELECT SUM( incidents
I want to combine these two queries into one: mysql_query(INSERT INTO categories (name, parent)
I would like to combine these four queries into one: SELECT COUNT(ID) FROM conversations
I have 2 lists each of equal size and am interested to combine these
I have these 2 queries that I would like to combine into one big
I have two arrays. $keys = array(1,2,3,6,9); //note that 9 does not exist as
Is it possible to combine these two queries to form one? First Query: SELECT

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.