Assuming your world is 2D,
[] [] []|[]
-----
[] [] [] []
[] [] [] []
[] [] [] []
and | and --- are walls
Method #1: enlarge your grid to include the wall intersections. So the size of the row and columns will be row+(row-1),col+(col-1)
this is your new array representation: Original row = 4, new row = 4+3 = 7. This will also create walls to check for diagonal movements.
[ ][ ][ ][ ][ ][|][ ]
[ ][ ][ ][ ][-][-][-]
[ ][ ][ ][ ][ ][ ][ ]
[ ][ ][ ][ ][ ][ ][ ]
[ ][ ][ ][ ][ ][ ][ ]
[ ][ ][ ][ ][ ][ ][ ]
[ ][ ][ ][ ][ ][ ][ ]
Method #2: using the 4x4 representation, create a wall class that stores the adjacent tiles coordinate. And after that create a list to store a list of walls.
Wall(Point x,Point y); // constructor
Wall wall1 = new Wall(new Point(0,2),new Point(0,3));
Wall wall2 = new Wall(new Point(0,2),new Point(1,2));
Wall wall3 = new Wall(new Point(0,3),new Point(1,3));
this representation, allows you to create rules such that 0,0 can go to 1,1 but 0,1 cannot go to 1,0. If you want a unidirectional wall, which might sound silly but who knows? You can modify your wall class constructor:
Wall(Point from,Point to);
Collision checking for method 1: when moving your character, after you move, if it lands on the wall, don't allow the movement.
Collision checking for method 2: when moving your character, cache where the character is from, and where the character will move to if the move is allowed, construct a new Wall object base on that and check if the Wall list contains the new Wall object.