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

  • Home
  • SEARCH
  • 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 8537477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:54:38+00:00 2026-06-11T10:54:38+00:00

I would like to convert / form the following arrays as example: Array (

  • 0

I would like to convert / form the following arrays as example:

Array ( [product_category] => for-women ) Array ( [brand] => 7-diamonds ) Array ( [size] => 12 ) Array ( [color] => 882536 )

Into one array that just merges each array pair and put them altogether :

Array ( [product_category] => for-women [brand] => 7-diamonds [size] => 12 [color] => 882536 )

I tried array_merge and it didn’t work. The array out put in my code is from $_SESSION which returns an array (a pair key=> value) like this:

foreach($_SESSION as $k => $v) {
    if (strstr($k, 'saved_query_') == true) {
        $saved = array_merge($v);
    }
}

So I get each array by looping through session which has a query, the result is array pair, I want to combine all pairs found (Do not know how to use array_merge in that case).

I tried array_combine and array_merge they do not seem like the functions I need based on php manual:

array_combine — Creates an array by using one array for keys and another for its values

Which I do not want to do, I just want to copy/move small arrays in one array, without changing any pairing/key/value.

  • 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-11T10:54:40+00:00Added an answer on June 11, 2026 at 10:54 am

    You can try using array_merge

    $array0 = Array ( "product_category" => "for-women" );
    $array1 = Array ( "brand" => "7-diamonds" ) ;
    $array2 = Array ( "size" => "12" ) ;
    $array3 = Array ( "color" => "882536" );
    
    $array = array_merge($array0,$array1,$array2,$array3);
    
    print_r($array);
    

    Output

    Array ( [product_category] => for-women [brand] => 7-diamonds [size] => 12 [color] => 882536 )
    

    See Demo

    * —– Update —– *

    If you are looking through a session

    $_SESSION = Array();
    $_SESSION[0] = Array("product_category" => "for-women");
    $_SESSION[1] = Array("brand" => "7-diamonds");
    $_SESSION[2] = Array("size" => "12");
    $_SESSION[3] = Array("color" => "882536");
    
    $final = array();
    foreach ( $_SESSION as $key => $value ) {
        $final = array_merge($final, $value);
    }
    
    print_r($final);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to convert the following string into an array/nested array and iterate
I would like convert an array in D of the form: string[] arrayStr =
I would like to convert numbers to the shorter form using NSNumberFormatter . For
I would like convert the below text into a nested array, something like you
I would like to convert a Dictionary to a string array (or list) The
I would like to convert flat form data to recursive JSON data in python
I would like to convert an entire form of data to a javascript object.
I would like to convert a Number form a String with such a method
How do I convert a html form to PDF. I would like to use
I would like to convert this piece of logic with purely matrix operations instead

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.