
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php $options = [ 'rootNode' => 'response' ]; // array_merge // the same key appearing later will overwrite echo print_r( array_merge ([ 'rootNode' => 'root' ], $options ), true); /** * output * * Array * ( * [rootNode] => response * ) */ // + syntax if it already exists + will NOT overwrite echo print_r([ 'rootNode' => 'root' ] + $options , true); /** * Output * * Array * ( * [rootNode] => root * ) **/ |
0 Comments