- print_r: documentation ( source)
- array_merge: documentation ( source)
<?php
$def = array(
1 => 'on',
2 => 'on',
3 => 'on'
);
$fill = array(
2 => 'off'
);
$res = array_merge($fill, $def);
$res2 = array_merge($def, $fill);
print_r($res);
print_r($res2);
function array_merge_custom($first, $second) {
$result = array();
foreach($first as $key => $value) {
$result[$key] = $value;
}
foreach($second as $key => $value) {
$result[$key] = $value;
}
return $result;
}
$res3 = array_merge_custom($def, $fill);
print_r($res3);