1 Matching Annotations
  1. Jun 2022
    1. <?php$base = array("orange", "banana", "apple", "raspberry");$replacements = array(0 => "pineapple", 4 => "cherry");$replacements2 = array(0 => "grape");$basket = array_replace($base, $replacements, $replacements2);print_r($basket);?> The above example will output: Array ( [0] => grape [1] => banana [2] => apple [3] => raspberry [4] => cherry )

      array_replace() replaces the values of array with values having the same keys in each of the following arrays.