Voting

: max(eight, zero)?
(Example: nine)

The Note You're Voting On

mail at romansklenar dot cz
15 years ago
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);

/*
correct output:

array(3) {
"id" => NULL
"login" => string(8) "john.doe"
"credit" => int(100)
}

your output:

array(3) {
"id" => int(2)
"login" => NULL
"credit" => int(5)
}
*/
?>

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

<< Back to user notes page

To Top