Questions tagged [array-merge]

Array-merge means elements of one or more arrays will be merged together into a single array.

Array-merge means merging the elements of one or more arrays together into a single array so that the values of one are appended to the end of the previous one.

array array_merge ( array $array1 [, array $... ] )

Example

$array1 = array("color" => "red", 2, 4);
$array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4);
$result = array_merge($array1, $array2);
print_r($result);

Result

Array
(
    [color] => green
    [0] => 2
    [1] => 4
    [2] => a
    [3] => b
    [shape] => trapezoid
    [4] => 4
)

Reference

819 questions
-3
votes
1 answer

How to combine two objects with same key name in JavaScript?

In my react app, I currently have two arrays with objects that I would like to combine. const cars = [ {'car': 'porsche', 'description': 'luxury', 'driverId': 4}, {'car': 'ferrari', 'description': 'beatiful', 'driverId': 2}, {'car':…
Judoboy Alex
  • 326
  • 1
  • 14
-3
votes
2 answers

Combining two arrays of strings into alphabetical order

I have two arrays of strings that I am trying to combine into one array. The two arrays are in alphabetical order. I have to combine them into alphabetical order. The way I attempted to do this was to create the combined list as the first list…
-3
votes
1 answer

Merge two arrays when string is identical

I have two arrays that I want to merge. I created the first one through a for() loop so that it includes the last seven days (only three here to keep it short): array(7) { [0]=> array(2) { ["created_at"]=> string(10) "2017-08-15" …
Magnar
  • 3
  • 2
-3
votes
1 answer

ordering non-decreasing functions then adding them in R

Need help with basic R function: Firstly order non-decreasing sequence from 4 different sequences and then order those 4 sequences into one. Im totally green in programing so please make it the simplest way possible. Edit1: puting some input data as…
michaszek
  • 3
  • 3
-3
votes
4 answers

Merge 2 different array and form a single array in php

I need to merge two different arrays and form a single array. The key field has the same value in both arrays. $array1=Array ( [0] => Array ( [key] => 39 [url] => www.youtube.com/embed/23sdg234 ) [1] => Array ( [key] => 39 [url] =>…
keepontrying
  • 557
  • 1
  • 4
  • 10
-3
votes
4 answers

Group row data in a 3d array by a column and merge the subarray data in each group

I have an array mentioned below. $array = array( '0' => array( 'names' => array(0 => 'Apple'), 'group' => 1 ), '1' => array( 'names' => array(0 => 'Mango'), 'group' => 1 …
-3
votes
4 answers

merging mutlidimensional array together to have a continous key

i want to merge this two arrays together Array ( [0] => Array ( [type] => Person [relevance] => 0.700000 [count] => 300 [text] => Chris ) ) Array ( [0] => Array ( …
-5
votes
1 answer

How to merge two object values with same keys

I am getting response as data [4] { { _id:"1" description:"desc" languageId:"5" title:"ttitle" } { [1]: _id:"2" description:"desc1" languageId:"4" title:"title2" } { [2]: _id:"3" description:"desc3" languageId:"4" title:"title2" } [3]: _id:"4"…
Shifali singla
  • 76
  • 1
  • 2
  • 8
-6
votes
1 answer

Merging two associative arrays in PHP

I have been trying to merge two associative arrays all day. But I don't know whether it is possible or not in PHP. first array 'images' => 0 => 'image_first' => string 'http://10.0.2.2/captcha-2/iphone.png' 1 => …
Hybrid Developer
  • 2,320
  • 1
  • 34
  • 55
1 2 3
54
55