FAQ Database Discussion Community


How do I obtain the duplicated values of two ArrayLists?

java,arraylist,duplicates,array-merge
Let's say I have 2 ArrayList of Points: (0,2)->(0,3)->(0,4) (0,2)->(0,3)->(0,6) And I want to obtain a new list : (0,2)->(0,3) How do I do that? current solution Using two foreach loops to compare the two lists, element by element. I think it's a very inefficient way. Are there any other...

I want to join 2 arrays with a standard usable

php,arrays,drupal,drupal-7,array-merge
I have array1 array1( 'orange' => 'orange' 'banana' => 'banana' ); and array2 array2( 0 => 'apple' 1 => 'watermellon' 2 => 'orange' 3 => 'potatoes' 4 => 'lemon' 5 => 'banana' ) and i want to take as reply array3( 2 => 'orange' 5 => 'banana' ) I need...

How to use array_merge to display non-quoted commands in PHP/Highcharts?

javascript,php,highcharts,array-merge
I am passing a JSON array with multiple Highcharts arguments to the client. In a few cases, I use an array_merge to insert after the allocation code a few extra things. This works fine as long as the argument being passed will be displayed in quotes, such as: $data_['xAxis'] =...

Merge 2 sorted arrays in C

c++,c,sorting,array-merge,array-algorithms
I'm writing code to merge 2 sorted arrays code is below void main() { int a[]={7}; int b[] = {8}; int ret; int *c; merge(a,b,c,1,1); } void merge(int *a, int *b,int *sorted, int i, int j) { int c1,c2,k=0; c1=0; c2=0; for(k=0;c1<i && c2< j;k++) { if(a[c1]<b[c2]) sorted[k]=a[c1++]; else sorted[k]=b[c2++];...

In php how to assign specific array key to main array key?

php,arrays,multidimensional-array,array-merge
I am getting this result after merge two arrays: Array ( [0] => Array ( [id] => 36 [banners] => Array ( [0] => 142606425210.jpg [1] => 142606425209.jpg ) ) [1] => Array ( [id] => 40 [banners] => Array ( [0] => 142606425209.jpg [1] => 142606425311.jpg ) ) )...

PHP Merge (Add) Two Arrays by Same Key

php,arrays,array-merge
I have two arrays. $a = array('a' => 2, 'b' => 5, 'c' => 8); $b = array('a' => 3, 'b' => 7, 'c' => 10); I want to merge these two arrays and get following result. $c = array('a' => 5, 'b' => 12, 'c' => 18); What is...

Laravel 5 / zofe/rapyd-laravel Datagrid : ErrorException in Factory.php line 150: array_merge(): Argument #2 is not an array

laravel,datagrid,array-merge
This is my first post on stackoverflow :) I am new to Laravel and tried to display an array into a grid. I choosed zofe/rapyd-laravel Datagrid, but even if it seems simple I cannot get it to display.. Here is my code : public function index() { $reader = Reader::createFromPath('../uploads/pcl.csv');...

How can I merge one array with values into an array with stdClass objects?

php,arrays,multidimensional-array,array-merge
I have two arrays and looking for the way to merge them. Standard array_merge() function don't work. Do you know any nice solution without foreach iteration? My first array: Array ( [0] => stdClass Object ( [field_value] => Green [count] => ) [1] => stdClass Object ( [field_value] => Yellow...

Push or Merge data into existing Array

php,arrays,array-merge,array-push
When working with existing code, it takes one array and places it into another in the fashion shown below. I believe the empty brackets are the same thing as simply pushing it and appending it to the first available index. $g['DATA'][] = $p; After this is done, I have my...

Having trouble with merge function algorithm in C++

c++,arrays,algorithm,merge,array-merge
I have been trying to figure out what could possibly be going wrong with the calling of these two functions for a while now and can't seem to identify it. When I call the merge function before the show function, it works fine and merges the two arrays and then...

PHP : merging array with same element

php,arrays,multidimensional-array,array-merge
I need a new array to merge all category_name with same exercise_name, i.e. it would be: Array ( [0] => stdClass Object ( [exercise_name] => Hang Clean [category_name] => Heavy,Pull,Core ) [1] => stdClass Object ( [exercise_name] => Ice Skaters [category_name] => Ground,Lower,Plyometrics ) [2] => stdClass Object ( [exercise_name]...