bsmither Posted October 23, 2014 Share Posted October 23, 2014 I've been searching for a science that will solve this analysis problem. Since I don't know what I'm looking for, I cannot properly express the task to accomplish. I have an eCommerce store selling a product that has (let's keep it simple) three properties and each property can hold any one of three possible relevant values (or null). Combinations: 3^3=27 A typical combination would be round/solid/blue, or cubic/squishy/white. The task is to efficiently eliminate that part of the array if any particular {set of values} is null. That is, if I currently have no pink items, the relevant sections of the array would get eliminated. Product variations with low n-values is easy to manually handle. But with five and above, that's the math(?) theory I am trying to know the name of. (I wonder if any Matlab manuals would give a clue.) I am trying this elimination of sections of an established array instead of rebuilding the array every time a value is locked in. On the other hand, maybe I'm trying to be too smart about this and should just let the server do the grunt work over and over. Quote Link to comment https://forums.phpfreaks.com/topic/292001-n-dimensional-array-optimizing-eliminations/ Share on other sites More sharing options...
requinix Posted October 23, 2014 Share Posted October 23, 2014 (edited) I'm wondering if you've given a complicated description of the following: shapes = { round, cubic, cylindrical } textures = { solid, squishy } colors = { red, orange, yellow, green, blue, purple, black, white } items = { { round, solid, blue }, { cubic, squishy, white }, { round, solid, orange }, { round, solid, white } } unused shapes = { round, cubic, cylindrical } - { round, cubic, round, round } = { cylindrical } unused textures = { solid, squishy } - { solid, squishy, solid, solid } = { } unused colors = { red, orange, yellow, green, blue, purple, black, white } - { blue, white, orange, white } = { red, yellow, green, purple, black }That's just a 2D array (1D is property, 2D is value) and you can get the "unused" values with array_diff. Edited October 23, 2014 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/292001-n-dimensional-array-optimizing-eliminations/#findComment-1494447 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.