Query: array_replace
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
ARRAY_REPLACE(3) 1 ARRAY_REPLACE(3) array_replace - Replaces elements from passed arrays into the first arraySYNOPSISarray array_replace (array $array1, array $array2, [array $...])DESCRIPTIONarray_replace(3) replaces the values of $array1 with values having the same keys in each of the following arrays. If a key from the first array exists in the second array, its value will be replaced by the value from the second array. If the key exists in the second array, and not the first, it will be created in the first array. If a key only exists in the first array, it will be left as is. If several arrays are passed for replacement, they will be processed in order, the later arrays overwriting the previous values. array_replace(3) is not recursive : it will replace values in the first array by whatever type is in the second array.PARAMETERSo $array1 - The array in which elements are replaced. o $array2 - The array from which elements will be extracted. o $... - More arrays from which elements will be extracted. Values from later arrays overwrite the previous values.RETURN VALUESReturns an array, or NULL if an error occurs.EXAMPLESExample #1 array_replace(3) example <?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 )SEE ALSOarray_replace_recursive(3), array_merge(3). PHP Documentation Group ARRAY_REPLACE(3)
Related Man Pages |
---|
array_diff_assoc(3) - php |
array_replace(3) - php |
array_intersect_assoc(3) - php |
array_merge(3) - php |
wincache_ucache_delete(3) - php |
Similar Topics in the Unix Linux Community |
---|
Using Bash scripting to compare arrays looking for matches |
Arrays in perl |
Signalsafe data structures |
Pointers and array |
Sum elements of 2 arrays excluding labels |