To get exactly same result like in PHP 5.3, the foreach loop in your code should look like:
<?php
...
$count = func_num_args();
for ($i = 1; $i < $count; $i++) {
...
}
...
?>
Check on this code:
<?php
$base = array('id' => NULL, 'login' => NULL, 'credit' => NULL);
$arr1 = array('id' => 2, 'login' => NULL, 'credit' => 5);
$arr2 = array('id' => NULL, 'login' => 'john.doe', 'credit' => 100);
$result = array_replace($base, $arr1, $arr2);
?>
Function array_replace "replaces elements from passed arrays into the first array" -- this means replace from top-right to first, then from top-right - 1 to first, etc, etc...