[ create a new paste ] login | about

Link: http://codepad.org/uAYCDQGl    [ raw code | output | fork ]

PHP, pasted on Mar 5:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
$arr = array( 'test', 'foo', 'bar' );
$arr2 = array( 'test2', 'foo2', 'bar2' );

print_r( array_merge($arr, $arr2) );
print_r( array_merge($arr2, $arr) );
print_r( $arr + $arr2 );
print_r( $arr2 + $arr );

$arr = array( 'key' => 'value', 'foo' => array( 'bar' ) );
$arr2 = array( 'key' => 'value2', 'foo' => array( 'bar2' ) );

print_r( array_merge($arr, $arr2) );
print_r( array_merge($arr2, $arr) );
print_r( $arr + $arr2 );
print_r( $arr2 + $arr );


Output:
Array
(
    [0] => test
    [1] => foo
    [2] => bar
    [3] => test2
    [4] => foo2
    [5] => bar2
)
Array
(
    [0] => test2
    [1] => foo2
    [2] => bar2
    [3] => test
    [4] => foo
    [5] => bar
)
Array
(
    [0] => test
    [1] => foo
    [2] => bar
)
Array
(
    [0] => test2
    [1] => foo2
    [2] => bar2
)
Array
(
    [key] => value2
    [foo] => Array
        (
            [0] => bar2
        )

)
Array
(
    [key] => value
    [foo] => Array
        (
            [0] => bar
        )

)
Array
(
    [key] => value
    [foo] => Array
        (
            [0] => bar
        )

)
Array
(
    [key] => value2
    [foo] => Array
        (
            [0] => bar2
        )

)


Create a new paste based on this one


Comments: