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
vote
3 answers

Merge/Append the differences between two 2d arrays to the intersection of the same two arrays to achieve a particular sort order

I have two arrays, the first one is the sorted version (sorted by the user) of the second one, but the second one can be shorter or longer than the first one. For example: $books_sorted = array( 0 => array( "title" => "In Search of Lost…
1
vote
3 answers

php array_diff wrong reuslt

Hello i have an array_dif function between 2 arrays and the result it's not as it should.I don't understand why it does not return the status as difference. First array is data second is row and the third is the result. In the result it should also…
chris227
  • 579
  • 9
  • 28
1
vote
1 answer

Save difference of two arrays in another array in PHP

I'm trying to save the difference of two arrays in a new one. I've used array_diff and the code I have right now is partially working but it seems that the new array saves the elements in wrong position.
Joe K.
  • 65
  • 1
  • 7
1
vote
1 answer

filter from array with multiple value php

$tick = file_get_contents('https://api.coinmarketcap.com/v2/ticker'); $data = json_decode($tick, TRUE); var_dump($data); result of $data when filter by this code : if($key == 1027) $me=$value; array (size=10) 'id' => int 1 'name' => string…
1
vote
1 answer

Filter a 2D Array From Elements of Another

I have two sets of numeric elements stored as 2D array. The values were grabbed from a column using .getValues(). One is a full list the other is a partial list. I want a function that returns full list minus partial list. The partialListArr may…
DanCue
  • 619
  • 1
  • 8
  • 17
1
vote
2 answers

Date and Time Delta between two Dates

I have a table structure like below for completion of the task against name , I want to take difference between End_Time to Start_time for each name. Can anyone please suggest time how to do this with python code. start_time End_Time …
DHANANJAY CHAUBEY
  • 107
  • 1
  • 2
  • 10
1
vote
3 answers

Filter 2d array by a flat, blacklist array

I have an array that looks like this.. $breadcrumbs = [ ['Home', 'homepage.html'], ['About', 'aboutpage.html'], ['Contact', 'contactpage.html'] ]; $remove = ['Home']; I am trying to use array_diff() to remove the Home entry from…
fightstarr20
  • 11,682
  • 40
  • 154
  • 278
1
vote
2 answers

Error when running my php script

I have these errors when running my script. failed to open dir: No such file or directory in /Applications/MAMP/htdocs/sites-store/word/word2.php on line 6 Warning: scandir(): (errno 2): No such file or directory in…
cachess
  • 163
  • 1
  • 5
  • 18
1
vote
4 answers

Javascript arrays and objects: Get differences and merge them

So I have this scenario where I have a client-app which sends data (array of objects) to a server which then forwards the data to other clients connected to this server. In the client-app, the data is constantly changing, meaning: Values change, new…
1
vote
1 answer

Remove values from array based on another array

I'm gonna need a little help from you guys to fix this little code. The idea is to remove any numbers that are inside $remove_str from $list_str. As you can see I've already tried to solve the problem by turning both strings into arrays and simply…
icecub
  • 8,615
  • 6
  • 41
  • 70
1
vote
1 answer

How to use array_diff for (.txt) files in PHP

The result is Array ( [0] => 12 [1] => 11 ) so 12 and…
Andrew
  • 243
  • 1
  • 10
1
vote
1 answer

How to tell if a value changed over dimension(s) in Pandas

Let's say that I have some customer data over some dates and I want to see if for example their address has changed. Over those dates. Ideally, i'd like to copy the two columns where the changes occurred into a new table or just get a metric for…
sc305495
  • 249
  • 3
  • 11
1
vote
2 answers

CSV file value comparison producing a new CSV file with the results

I have two .csv files with a single row but with many columns. I wish to compare the data in the columns (except the first 3 columns) and output a new .csv containing the subtraction of the files, computed as baseline - test. test1.csv 20170223,…
Anon
  • 11
  • 2
1
vote
1 answer

add an item to an array IF conditional statement

I have a protected array. class Tric_FullCircle_Model_Product_Adapter extends OnePica_FullCircle_Model_Product_Adapter { /** * Global company number */ protected $_globalCompanyNumber = null; /** * Tax Classes */ …
thismethod
  • 523
  • 1
  • 6
  • 25
1
vote
3 answers

Compare two 2-dimension arrays in PHP with array_diff error

The question could have been different, like : Compare two tables in mySQL on a specific metric. My tables have a dimension (date) and a metric (number) and I want to check if I am getting the same number for the same date. As a solution I started…
Datacrawler
  • 2,780
  • 8
  • 46
  • 100