Your Location is: Home > Php

Points with cardinal directions

From: Jordan View: 3675 Jaro Varga 
 php

Question

I have a PHP array with points (rooms):

array(38) {
  [90]=> array(3) {
            ["environment"]=> array(2) {
                ["name"]=> string(6) "Garden"
                ["color"]=> int(2)
                }
            ["coordinates"]=> array(2) {
                ["x"]=> int(2)
                ["y"]=> int(-1)
                }
            ["exits"]=> array(3) {
                [0]=> array(2) {
                    ["direction"]=> string(4) "west"
                    ["target"]=> int(91)
                    }
                [1]=> array(2) {
                    ["direction"]=> string(5) "north"
                    ["target"]=> int(89)
                    }         
                [2]=> array(2) {
                    ["direction"]=> string(5) "south"
                    ["target"]=> int(92)
                    }         
            }
  }
...

I have no record of which point is first. The result should be a map with points on grid with the ability to enter any (start) point and the rest will be drawn.

Any ideas how merge these points using cardinal directions (exits)?

Best answer