Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3395964
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:21:05+00:00 2026-05-18T04:21:05+00:00

My question is instead of using coordinates to move can i assign numbers and

  • 0

My question is instead of using coordinates to move can i assign numbers and letters so i can move with those values

Edit: I am outputting the board to html 8×8 table

$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),
);

so when the user inputs : From: F1 to: G2 the pieces move

wouldn’t it be better is i do this

Array ( 'A' => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 ) 
        'B' => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 ) 
        'C' => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 ) 
        'D' => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 ) 
        'E' => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 ) 
        'F' => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 ) 
        'G' => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 ) 
        'H' => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 ) 

    ); 

parseSquareFrom

function parseSquareFrom() {
    if (strlen($square) != 2) {
    return FALSE;
    }

    $coords = array(ord('A') - ord($square[0]),
            $square[1] - 1);


    // Perform bounds-checking.
    if ($coords[0] < 0 || $coords[0] > 7 || $coords[1] < 0 || $coords[1] > 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
}

and parseSquareTo

function parseSquareTo() {
    if (strlen($square1) != 2) {
    return FALSE;
    }

  $coords1 = array(ord('A') - ord($square1[0]),
            $square1[1] - 1);


    // Perform bounds-checking.
    if ($coords1[0] < 0 || $coords1[0] > 7 || $coords1[1] < 0 || $coords1[1] > 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
}

can i use that with this 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

or is the $piece = $board[$coords1[0]][$coords1[1]]; cannot be used

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:21:05+00:00Added an answer on May 18, 2026 at 4:21 am

    Yes: Parse the input string into an X,Y pair. For example:

    function parseSquare($square) {
        if (strlen($square) != 2) {
            return FALSE;
        }
    
        $coords = array(ord('A') - ord($square[0]),
                        $square[1] - 1);
    
        // Perform bounds-checking.
        if ($coords[0] < 0 || $coords[0] > 7 || $coords[1] < 0 || $coords[1] > 7) {
            return FALSE;
        }
    
        return $coords;
    }
    

    So given a square string like $square = "F5";

    $coords = parseSquare($square);
    if ($coords === FALSE) {
        // Invalid input, handle this case.
    } else {
        $piece = $board[$coords[0]][$coords[1]]; // for example
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: now the question becomes, how do I tell Sajax to use POST instead
Somewhat related to my question about integers instead of decimals; my vendor provides a
My question is the antithesis of How do I process input immediately instead of
The question is in the title, why : return double.IsNaN(0.6d) && double.IsNaN(x); Instead of
Question Can I build a image database/library that has an e-commerce style checkout system
What are the security implications of websites accessing database views instead of using stored
Question as stated in the title.
Question is pretty self explanitory. I want to do a simple find and replace,
Question Alright, I'm confused by all the buzzwords and press release bingo going on.
Question in the title. And what happens when all 3 of $_GET[foo] , $_POST[foo]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.