Unix and Linux Discussions Tagged with arrays |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
21 |
6,838 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,494 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
3,866 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
3,941 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
2,176 |
Shell Programming and Scripting |
|
|
|
4 |
1,226 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
3,409 |
Programming |
|
|
|
2 |
2,493 |
Shell Programming and Scripting |
|
|
|
7 |
5,122 |
UNIX for Beginners Questions & Answers |
|
|
|
5 |
2,446 |
Shell Programming and Scripting |
|
|
|
6 |
3,919 |
UNIX for Dummies Questions & Answers |
|
|
|
15 |
9,055 |
Shell Programming and Scripting |
|
|
|
8 |
8,112 |
Programming |
|
|
|
2 |
1,885 |
Shell Programming and Scripting |
|
|
|
10 |
7,861 |
Shell Programming and Scripting |
|
|
|
6 |
2,408 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
16,883 |
Shell Programming and Scripting |
|
|
|
4 |
4,184 |
Programming |
|
|
|
5 |
1,849 |
Shell Programming and Scripting |
|
|
|
5 |
4,475 |
Homework & Coursework Questions |
|
|
|
3 |
2,565 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,727 |
Shell Programming and Scripting |
|
|
|
1 |
2,620 |
Shell Programming and Scripting |
|
|
|
1 |
2,471 |
Shell Programming and Scripting |
|
|
|
1 |
3,358 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
4,249 |
Emergency UNIX and Linux Support |
|
|
|
7 |
13,081 |
Shell Programming and Scripting |
|
|
|
12 |
29,867 |
Shell Programming and Scripting |
|
|
|
7 |
19,503 |
Shell Programming and Scripting |
|
|
|
0 |
5,209 |
Shell Programming and Scripting |
|
|
|
0 |
2,733 |
Shell Programming and Scripting |
|
|
|
3 |
4,113 |
Web Development |
|
|
|
1 |
3,945 |
Shell Programming and Scripting |
|
|
|
3 |
3,115 |
Shell Programming and Scripting |
|
|
|
1 |
5,417 |
Shell Programming and Scripting |
|
|
|
3 |
2,425 |
Shell Programming and Scripting |
|
|
|
1 |
3,982 |
Shell Programming and Scripting |
|
|
|
2 |
9,584 |
Shell Programming and Scripting |
|
|
|
4 |
10,255 |
Shell Programming and Scripting |
|
|
|
1 |
1,424 |
Shell Programming and Scripting |
ARRAY_REPLACE(3) 1 ARRAY_REPLACE(3)
array_replace - Replaces elements from passed arrays into the first array
SYNOPSIS
array array_replace (array $array1, array $array2, [array $...])
DESCRIPTION
array_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.
PARAMETERS
o $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 VALUES
Returns an array, or NULL if an error occurs.
EXAMPLES
Example #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 ALSO
array_replace_recursive(3), array_merge(3).
PHP Documentation Group ARRAY_REPLACE(3)