함수 array merge()

  다른 뜻에 대해서는 concat() 문서를 참조하십시오.
  다른 뜻에 대해서는 SQL MERGE 문서를 참조하십시오.
array_merge
array concat
concat
+

1 Bash[ | ]

ARR1=("John Smith" "Jane Doe")
ARR2=("Mike Barnes" "Kevin Patterson")
MERGED=("${ARR1[@]}" "${ARR2[@]}")
for VALUE in "${MERGED[@]}"; do echo "[$VALUE]"; done
# [John Smith]
# [Jane Doe]
# [Mike Barnes]
# [Kevin Patterson]
ARR1=("John Smith" "Jane Doe")
ARR2=("Mike Barnes" "Kevin Patterson")
MERGED=("${ARR1[@]}")
MERGED+=("${ARR2[@]}")
for VALUE in "${MERGED[@]}"; do echo "[$VALUE]"; done

2 JavaScript[ | ]

var arr1 = ['a', 'b'];
var arr2 = ['c', 'd', 'e'];
var merged = arr1.concat(arr2);

console.log( arr1 );
// ["a", "b"]
console.log( merged );
// ["a", "b", "c", "d", "e"]
var arr1 = ['a', 'b'];
var arr2 = ['c', 'd', 'e'];
Array.prototype.push.apply(arr1, arr2);
console.log( arr1 );
// ["a", "b", "c", "d", "e"]

3 PHP[ | ]

$arr1 = array('a', 'b');
$arr2 = array('c', 'd');
$merged = array_merge($arr1, $arr2);
print_r($merged);
// Array
// (
//     [0] => a
//     [1] => b
//     [2] => c
//     [3] => d
// )

4 Python[ | ]

a = ['Apple', 'Banana']
b = ['Cranberry', 'Pear']
c = a + b
print( c )
# ['Apple', 'Banana', 'Cranberry', 'Pear']

5 Perl[ | ]

my @a = ('Apple', 'Banana');
my @b = ('Cranberry', 'Pear');
my @c = (@a, @b);
print @c;
#AppleBananaCranberryPear

6 Ruby[ | ]

a = ['Apple', 'Banana']
b = ['Cranberry', 'Pear']
c = a + b
puts c
# Apple
# Banana
# Cranberry
# Pear

7 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}