Given two array arr1 and arr2 and the task is to append one array to another array.
Input : arr1 = [ 1, 2 ] arr2 = [ 3, 4 ] Output : arr1 = [ 1, 2, 3, 4 ] Input : arr1 = [ "Geeks", "g4g" ] arr2 = [ "GeeksforGeeks" ] Output : arr1 = [ "Geeks", "g4g", "GeeksforGeeks" ]
Using array_merge function: This function returns a new array after merging the two arrays.
arr1 Contents: Geeks g4g GeeksforGeeks Computer science portal
Using array_push Method: This method pushes the second array element in the first array in-place.
arr1 = 1 2 3 4
Note: Another way to do it is by ‘ + ‘ but it gives fatal warning in the newer versions, hence it is not recommended.
- p5.js | append() function
- ArrayObject append() function in PHP
- jQuery | append() Method
- Form N-copy string with add, remove and append operations
- C# | Array.BinarySearch(Array, Object, IComparer) Method
- Find the Initial Array from given array after range sum queries
- kasai’s Algorithm for Construction of LCP array from Suffix Array
- Array.BinarySearch(Array, Object) Method with examples in C#
- Replace every elements in the array by its frequency in the array
- What is the difference between array_merge and array + array in PHP?
- Array.BinarySearch(Array, Int32, Int32, Object) Method with examples in C#
- How to sort an Array in C# | Array.Sort() Method | Set – 5
- How to sort an Array in C# | Array.Sort() Method Set – 2
- How to sort an Array in C# | Array.Sort() Method | Set – 4
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.