51 questions
1 vote
1 answer
52 views
PHP combine two associative arrays with different keys
I want to combine two associative arrays with different amount of keys and keep all the keys in the final array even if they are null or empty I have tried array_merge but the keys that are not ...
1 vote
4 answers
114 views
Use flat array's values to generate an associative array whose keys and values are given a static prefix
Is there a shorthand for the following code: $result = array_combine( array_map(fn($elem) => "key_$elem", $array), array_map(fn($elem) => "value_$elem", $array) ); ...
-1 votes
3 answers
40 views
foreach array_combine two array by php
There are two arrays that One is the correct answers and the other is the user's answer. My Php: $i=1; $correct = array('a','d','c','a','b','c'); $user = array('a','c','c','a','c','c'); foreach (...
-1 votes
1 answer
59 views
How to combine multiple arrays of duplicate first element (Combine only second element) in PHP?
I've an array of arrays in which I've 2 values in each array first one is personID and second one is Skill, there are multiple skills of same persons I need all same skills to add in an array with ...
0 votes
2 answers
37 views
combine 2 array with same key into 1 array
I have 2 Array: $arr1 = Array ( [2] => Array ( [0] => 41000 [1] => 31079 ) [3] => Array ( [0] => 42963 [1] => 41189 ) ) $arr2 = Array ( [2] => ...
-1 votes
2 answers
138 views
loop through an array and compare object values to combine respective arrays
Here is my array , I need to loop through this array and check if objects with same docId exists and if they do, I have to combine jArray of these objects FinalArray = [ { "jArray&...
1 vote
1 answer
44 views
how to combine an array with the same keyon react?
i have an output like this: [ { GolonganName: '3B - Niaga Besar', data: [ 172000 ] }, { GolonganName: '3A - Niaga Kecil', data: [ 76700 ] }, { GolonganName: '2B - Rumah Tangga Menengah', data: [ ...
0 votes
1 answer
213 views
Use column values from one subarray as keys for anotheer subarray's values
I have an object as below, {"metaData":[{"name":"a"},{"name":"b"}],"rows":[[1,2],[3,4],[5,6]]} I would like to change it to [["a"=...
0 votes
0 answers
40 views
I don't want to combine two obyes and have keys
I combined 2 objects as below, but I don't want the keys to be in the output I get. $link1 = '{"Success":true,"Result":[{"eventId":650810,"sportId":"2"...
0 votes
1 answer
2k views
Plotting multiple data sets as one average and adding error bars- matplotlib
I need to analyze some data taken in my lab but it goes beyond my limited programming skills. I have multiple sets of similar data and I need to take the average of all of these and plot that with ...
-2 votes
1 answer
158 views
Combine two arrays with multiple values and same keys
I have two arrays with keys and values and i want to combine them: Array 1 [0]=>string "Width" [1]=>string "Height" [2]=>string "Length" [3]=>string "...
0 votes
2 answers
64 views
php: combine multiple arrays value into one array preserving keys
I have multiple arrays structured like these: $array1 = ["aaa" => 1, "bbb" => 1]; $array2 = ["aaa" => 12, "bbb" => 12]; $array3 = ["bbb" =&...
1 vote
2 answers
398 views
How do I combine two rows with a the same identity?
I'm trying to combine 2 rows with the same identity. I've been looking for a solution, but somehow can't find a working solution. I'm trying to make a tracker for my stocks, but I want it to combine ...
-2 votes
2 answers
173 views
Combine Two Multidimensional Arrays on matching key values in PHP [closed]
Problem i have two multidimensional arrays that look like this, 1st Array array( [0] => Array ( [course_id] => 10 [topic] => Booda-hood, advice and an important ...
0 votes
2 answers
420 views
PHP array_combine if not null
I want to combine data only if value is exist. example: // array 1 array:4 [▼ 0 => "qwfd" 1 => "qw2e3" 2 => null 3 => null ] // array 2 array:4 [▼ 0 => &...