Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/05/2009, 16:44
okram
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Mapa plano PHP

:

Y si usas matrices?

Código php:
Ver original
  1. $stands = array(
  2.     1 => 0, 2 => 1, 3 => 0, 4 => 1, 5 => 0,
  3.     6 => 1, 7 => 0, 8 => 0, 9 => 1, 10 => 1,
  4.     11 => 0, 12 => 0, 13 => 0, 14 => 1, 15 => 1,
  5.     16 => 0, 17 => 1, 18 => 1, 19 => 1, 20 => 1,
  6.     21 => 1, 22 => 0, 23 => 1, 24 => 1, 25 => 1,
  7.     26 => 1, 27 => 0, 28 => 0, 29 => 1, 30 => 1
  8. );
Aquellos con valor 1 son ocupados, los de valor 0 son libres.

Ahora, podrías usar tambien matrices tipo plano cartesiano:

Código php:
Ver original
  1. $stands = array(
  2.     0 => array(0 => 0, 1 => 1, 2 => 0, 3 => 0, 4 => 1),
  3.     1 => array(0 => 1, 1 => 0, 2 => 1, 3 => 0, 4 => 1),
  4.     2 => array(0 => 1, 1 => 1, 2 => 1, 3 => 1, 4 => 0),
  5.     3 => array(0 => 0, 1 => 0, 2 => 0, 3 => 1, 4 => 1),
  6.     4 => array(0 => 1, 1 => 1, 2 => 1, 3 => 1, 4 => 0)
  7. );