Array-replace means elements of one array will be replaced in the other array.
Questions tagged [array-replace]
9 questions
49
votes
7 answers
How to replace elements in array with elements of another array
I want to replace elements in some array from 0 element, with elements of another array with variable length. Like:
var arr = new Array(10), anotherArr = [1, 2, 3], result;
result = anotherArr.concat(arr);
result.splice(10, anotherArr.length);
Is…

Artem Svirskyi
- 7,305
- 7
- 31
- 43
4
votes
1 answer
APL: array's element replacement and multiplication
Let's say in APL language, I have a 2D array of shape 10x3. I cannot figure it out how to:
replace all the occurrence of some specific numbers (e.g. 1, 2, 3, 4) in the entire array with 0, 10, 100, 1000 respectively. So I want to map 1 to 0, 2 to…

Parisa Zaeri
- 83
- 3
1
vote
3 answers
How to merge two multi dimensional arrays by key value in php?
I have two arrays
$arr1 = [
['month' => 1],
['month' => 2],
['month' => 3],
['month' => 4]
];
$arr2 = [
['month' => 3, 'info' => 'Alpha'],
['month' => 4, 'info' => 'Beta']
];
I have tried array_merge &…

Karthikeyan Raju
- 13
- 3
0
votes
0 answers
how to change value of an array based on value php
i try to change roman numerals in a string to numeric value.
In order to find and replace the roman numerals in the array i tried str_replace()
but the Output confirms that the method is not working.
$string = "This is a Test String with Roman…

LeGerman
- 1
0
votes
3 answers
How to replace value of array in javascript with another value of array?
I'm trying to replace values from an array which are present in a string with another array. What is the best way to do this in Javascript?
here is my code :
var string = "I've to but the Item1 along with Item2 and Item3. From the Item4."
var array1…

Aman Dutt
- 33
- 4
0
votes
0 answers
Postgres array_replace function not existing in version 11, 12
Quite frustrating that array_replace function exists in version 9, but not in 11 or 12.
Is there a way to activate this function or something of that sort?
Please help
I am running Postgres 11.5, select version() gives me the…

Mav S.
- 21
- 5
0
votes
2 answers
replace all values in array that have "o" letter in php
This is my array
$arr = array("dog", "cat", "lion");
Now i wanna replace any value that has the letter o with 0.
Example :
$arr = array("d0g", "cat", "li0n");
This is my method for doing this :
$arr = array("dog", "cat", "lion");
$arr2 =…
user12670050
0
votes
4 answers
Merge/Replace associative rows from one array with the associative rows of another array
I have 2 arrays - one is hard coded and the other is data retrieved from a database.
I am trying to merge them but I'm having unexpected results.
This is the first array:
$base_image_array = [
["product_image_one" => ""],
…

jagershark
- 1,162
- 3
- 15
- 27
0
votes
4 answers
Replace elements in an associative array using another associative array
How can assign the values from one array to another array? For example:
//array with empty value
$targetArray = array(
'a' => '',
'b' => '',
'c' => '',
'd' => ''
);
// array with non-empty values, but might be missing keys from the…

user1480765
- 177
- 3
- 11