How do I combine 2 arrays?

0 favourites
  • 5 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hello,

    I've been struggling to combine 2 arrays into one without messing up all of the data.

    Both arrays have 2 columns. First column contains IDs and the second one contains prices. I need a third array with all of the IDs (some are the same in array 1 and 2) and prices from both arrays, each in its own column - so array 3 has 3 columns.

    I've been trying with For each loops in different ways but I always end up with either just 1 value (the loop doesn't run correctly) or I'm just overwriting array 1 with array 2 instead of combining them.

    Any help would be much appreciated!

    Tagged:

  • Here's one way.

    https://www.dropbox.com/scl/fi/tbsd0woz3v14csc10q8mz/array_combine.capx?rlkey=m5kqrkoo9m8g0thdttvnxg1ve&dl=1
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you for you capx but I can't access it; I tried from different computers (on different networks) and I always get Error (400); something went wrong

  • Try again. Dropbox changed the format of its links which seem to break on this site.

  • I'm sorry for such a late reply but I was so happy with your solution I got utterly distracted.

    Thank you, you are a life saver :)

    Now, all I have to do is set up something like excel’s vlookup function and life will be sunshine and daisies again :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)