Questions tagged [array-difference]

Used for questions concerning the difference between arrays. For example, where elements in two arrays differ from each other, or subtracting the content of one array from another. Since the tag can be broadly applied to any programming language that supports arrays, use use one or more additional tags in order to help identify the specific language the question relates.

An array is a data structure that encompasses a group of elements. When working with arrays there can be a requirement to determine the difference between two or more arrays, and this tag is for questions relating specifically to finding that difference.

The difference between arrays can be determined in a number of ways, including finding where elements within the array differ, and can include operations such as subtracting the contents of one array from another to produce an outcome.

273 questions
-1
votes
1 answer

What array structure is in C# but not in C/C++/Java?

I'm preparing for exams and there's this question I can't find answer to. Read bunch of articles, closest I found was Arrays in C# come in three flavors: single-dimensional, multidimensional rectangular arrays (like the C++ multidimensional…
Erndob
  • 2,512
  • 20
  • 32
-1
votes
3 answers

How is array.filter checking for Array differences in my sample code?

I am trying to understand how array.filter is returning array differences by checking if indexOf(x) is equal to -1? Why -1? function array_diff(a, b) { return a.filter(function(x) { return b.indexOf(x) == -1; }); }
Felice
  • 571
  • 1
  • 7
  • 22
-1
votes
1 answer

array_diff doesn't seem to be working for me

I'm pulling a feed of YouTube videos from a user account, which are then held in an array. I've been asked to hide certain videos from the array, so I thought I could do this using array_diff, and creating an array containing the IDs of the videos I…
Lee
  • 4,187
  • 6
  • 25
  • 71
-1
votes
1 answer

comparing two arrays and return difference of arrays

My old array data: [Job] => Array ( [id] => 2 [job_state_id] => 14 [assigned_to_id] => [patient_id] => 2 [prescription] => main [case_type_id] => 1 …
Ali
  • 346
  • 2
  • 5
  • 20
-1
votes
1 answer

Find Array keys with similar names and rename it

I'm looking for a function that finds array keys with similar names and rename it. Example: Array('Joes house' => 'some text', 'Joe`s House' => 'more Text', 'Bob' => 'text...') Result: Array('New Key' => 'some text', 'New Key' => 'more Text', 'Bob'…
-1
votes
1 answer

compare two worksheets (with different number of rows on each sheet) and to get the list of not matching rows

Below is my requirement 1.Two sheets are available , say Sh1, Sh2 2.Row count differs between both the sheets(row count may/may not be the same between them) 3.Used Column of the sheets varies for data considered for comparison But at any given…
-2
votes
2 answers

array_diff for a complex xml

I have this xml that contains four text messages and i have converted that into an array. The xml > > >
Gandalf
  • 1
  • 29
  • 94
  • 165
-2
votes
1 answer

Laravel array_diff attributes

I'm trying to implement a RecordsActivity trait like in the Birdboard example on Laracasts. Here's Jeffrey's code updated for Laravel >=5.7: /** * Fetch the changes to the model. * * @return array|null */ protected function activityChanges() { …
Erich
  • 2,408
  • 18
  • 40
-2
votes
2 answers

PHP array_diff_key() is empty but should not

I query a series of tables in order to print these, and I want to print all keys of each table even if the values are empty, but a specific set of keys which are the same for each table shall not be printed. My query and fetch of the result in an…
Mich
  • 19
  • 6
-2
votes
2 answers

array_diff return a string without an array

I'm trying to clean my db if($var == true){ $db = file('db.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); shuffle($db); $db2 = file('db2.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $cleaner = array_unique ($db); …
-2
votes
1 answer

how can i compare an array values with subarray values

I try to get the differences between two arrays I have one big array with subarray and a small simple array. I want to get the difference from the big array. I use this to get the differences between 2 arrays, but working with subarray is someting…
oxido
  • 1
  • 4
-2
votes
1 answer

script to compare HTTP headers

I am looking for a way to write a function in a script to show what differences there are between array values Edit: added PHP code (and simplified...) Array ( [0] => HTTP/1.1 200 OK [Content-Type] => text/html; charset=UTF-8 …
JohnSnow
  • 163
  • 4
  • 16
-2
votes
2 answers

how to use array_diff

this is the print_r of the arrays and the last one is the result: Array ( [0] => 28 [1] => 29 [2] => 30 [3] => 31 [4] => 32 [5] => 33 [6] => 34 ) Array ( [0] => 28 [1] => 29 [2] => 30 [3] => 31 [4] => 32 [5] => 33 [6] => 34 [7] => 35 )…
webli
  • 1
  • 6
-2
votes
3 answers

how do i compare a number in one array with a number in another array and find the difference? im using C#

I got the following problem, i can't figure out how to compare the two arrays and display the difference between the two or show that it is a tie. Please help with this exercise. The code that I currently have does not allow me to find the…
-2
votes
4 answers

Compare and replace values in array

I need compare 2 arrays , the first array have one order and can´t change , in the other array i have different values , the first array must compare his id with the id of the other array , and if the id it´s the same , take the value and replace…
1 2 3
18
19