Written by James McDonald

May 27, 2022

<?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

Submit a Comment

Your email address will not be published.

You May Also Like…

MacOS USB Creator

Just toasted my Windows 10 Pro install with a Windows 11 upgrade. Think it will be unrecoverable (because of Bitlocker...