Selacius Posted December 11, 2010 Share Posted December 11, 2010 I have two multidimensional arrays, one is my base array which I am building on, and the second is which I will be using to build the first. The first array will be filled with "wall" values (my range is -13 to 13 in both the y and x planes). My second array will be filled with "floor" values and can range in size across the x and y planes, which will correlate with the same location in the primary array. For example:My second array goes from y = 0 to y = 5, and x = 0 to x = 5, this correlates to y = 0 to y = 5, and x = 0 to x = 5 in the main array. I want to now compare the 2nd array to the first and check to see if for all values of array 2 that array one is walls. Basically I am creating a map and do not want any overlap between rooms (array 2). I am currently checking with a bunch of for loops, but this is time intensive and often timeouts on me. Also if there is an easy way to insert array 2 into array 1 after determining whether the location is void of any floors, that would be helpful. I once again am using for statements and it is time intensive. Link to comment Share on other sites More sharing options...
gar onn Posted December 11, 2010 Share Posted December 11, 2010 I don't fully understand you question but I think this function will help you...function array_diff( array $array1 , array $array2 [, array $ ... ] ) Returns an array containing all the entries from array1 that are not present in any of the other arrays. Link to comment Share on other sites More sharing options...
Selacius Posted December 11, 2010 Author Share Posted December 11, 2010 Basically I am looking for a quick way to check a section of my primary array (the section constraints defined by array 2) in order to see if the section consists of all "wall" values or a "floor" component is present. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.