title: Assigning values to a multi-dimensional array for checkers
body: <p>My question is instead of using coordinates to move can i assign numbers and letters so i can move with those values</p>
  
  <p>Edit: I am outputting the board to html 8x8 table</p>
  
  <pre><code>$square = array( //    A B C D E F G H     
                 0 array(0,0,0,0,0,0,0,0),
                 1 array(0,0,0,0,0,0,0,0),
                 2 array(0,0,0,0,0,0,0,0),
                 3 array(0,0,0,0,0,0,0,0),
                 4 array(0,0,0,0,0,0,0,0),
                 5 array(0,0,0,0,0,0,0,0),
                 6 array(0,0,0,0,0,0,0,0),
                 7 array(0,0,0,0,0,0,0,0),
  );
  </code></pre>
  
  <p>so when the user inputs : From: F1 to: G2 the pieces move</p>
  
  <p>wouldn't it be better is i do this</p>
  
  <pre><code>Array ( 'A' =&gt; Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 0 [3] =&gt; 0 [4] =&gt; 0 [5] =&gt; 0 [6] =&gt; 0 [7] =&gt; 0 ) 
          'B' =&gt; Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 0 [3] =&gt; 0 [4] =&gt; 0 [5] =&gt; 0 [6] =&gt; 0 [7] =&gt; 0 ) 
          'C' =&gt; Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 0 [3] =&gt; 0 [4] =&gt; 0 [5] =&gt; 0 [6] =&gt; 0 [7] =&gt; 0 ) 
          'D' =&gt; Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 0 [3] =&gt; 0 [4] =&gt; 0 [5] =&gt; 0 [6] =&gt; 0 [7] =&gt; 0 ) 
          'E' =&gt; Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 0 [3] =&gt; 0 [4] =&gt; 0 [5] =&gt; 0 [6] =&gt; 0 [7] =&gt; 0 ) 
          'F' =&gt; Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 0 [3] =&gt; 0 [4] =&gt; 0 [5] =&gt; 0 [6] =&gt; 0 [7] =&gt; 0 ) 
          'G' =&gt; Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 0 [3] =&gt; 0 [4] =&gt; 0 [5] =&gt; 0 [6] =&gt; 0 [7] =&gt; 0 ) 
          'H' =&gt; Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 0 [3] =&gt; 0 [4] =&gt; 0 [5] =&gt; 0 [6] =&gt; 0 [7] =&gt; 0 ) 
  
      ); 
  </code></pre>
  
  <p>parseSquareFrom </p>
  
  <pre><code>function parseSquareFrom() {
      if (strlen($square) != 2) {
      return FALSE;
      }
  
      $coords = array(ord('A') - ord($square[0]),
              $square[1] - 1);
  
  
      // Perform bounds-checking.
      if ($coords[0] &lt; 0 || $coords[0] &gt; 7 || $coords[1] &lt; 0 || $coords[1] &gt; 7) {
      return FALSE;
      }
  
      return $coords;
  }
  $coords = parseSquare($square);
  if ($coords === FALSE) {
      // Invalid input, handle this case.
  } else {
      $piece = $board[$coords[0]][$coords[1]]; // for example
  }
  </code></pre>
  
  <p>and parseSquareTo</p>
  
  <pre><code>function parseSquareTo() {
      if (strlen($square1) != 2) {
      return FALSE;
      }
  
    $coords1 = array(ord('A') - ord($square1[0]),
              $square1[1] - 1);
  
  
      // Perform bounds-checking.
      if ($coords1[0] &lt; 0 || $coords1[0] &gt; 7 || $coords1[1] &lt; 0 || $coords1[1] &gt; 7) {
      return FALSE;
      }
  
      return $coords1;
  }
  
  $coords1 = parseSquare($square);
  if ($coords1 === FALSE) {
      // Invalid input, handle this case.
  } else {
      $piece = $board[$coords1[0]][$coords1[1]]; // for example
  }
  </code></pre>
  
  <p>can i use that with this code</p>
  
  <pre><code>    $board[$coords1[0]-1][$coords1[1]+1] = $board[$coords[0]][$coords[1]];
      $board[$coords[0]][$coords[1]] = 0;
  
      //eating action
      $board[$coords1[0]][$coords1[1]] = 0;
      $board[$coords1[0]-2][$coords1[1]+2] = $board[$coords[0]][$coords[1]];
  
      //if player is 'up' then the value of $way is 1 so
        $board[$x+(-1*$way)][$y+(1*$way)] = $board[$coords[0]][$coords[1]]; // position 2,2 becomes 1,3
     //if player is not 'up' then the value of $way is -1 so
        $board[$x+(-1*$way)][$y+(1*$way)] = $board[$coords[0]][$coords[1]]; // position 2,2 becomes 3,1
  </code></pre>
  
  <p>or is the $piece = $board[$coords1[0]][$coords1[1]]; cannot be used</p>