Categories
PHP+MySQL

二次元配列での array_merge

基本であることはわかっているものの、改めて確認したい気分になることがあるため。。。

$a = array(
		array( 0, 1, 2, 3, 4 ),
		array( 10, 11, 12, 13, 14 ),
		array( 20, 21, 22, 23, 24 )
	);

$b = array(
		array( 50, 51, 52, 53, 54 ),
		array( 60, 61, 62, 63, 64 ),
		array( 70, 71, 72, 73, 74 )
	);
print_r( array_merge( $b, $a ) );

結果は。

Array
(
    [0] => Array
        (
            [0] => 50
            [1] => 51
            [2] => 52
            [3] => 53
            [4] => 54
        )

    [1] => Array
        (
            [0] => 60
            [1] => 61
            [2] => 62
            [3] => 63
            [4] => 64
        )

    [2] => Array
        (
            [0] => 70
            [1] => 71
            [2] => 72
            [3] => 73
            [4] => 74
        )

    [3] => Array
        (
            [0] => 0
            [1] => 1
            [2] => 2
            [3] => 3
            [4] => 4
        )

    [4] => Array
        (
            [0] => 10
            [1] => 11
            [2] => 12
            [3] => 13
            [4] => 14
        )

    [5] => Array
        (
            [0] => 20
            [1] => 21
            [2] => 22
            [3] => 23
            [4] => 24
        )

)

[mokurenCB]