<?php
require("../kpregs.php");
/*
Check if a string is a valid chess square
*/
// Checking a single chess square
$square = "a4";
if (kpreg_is_valid_chess_squares($square))
echo("Valid chess square!");
else
echo("Invalid chess square!");
// Checking multiple chess squares
$squares = "a4,b6,h8, a2, f4 , a3";
if (kpreg_is_valid_chess_squares($squares,0,1,8)) // min 1 square, max 8 squares
echo("Valid chess squares!");
else
echo("Invalid chess squares!");
// Checking a single "to" square
$square = "a1-a3";
if (kpreg_is_valid_chess_squares($square,1))
echo("Valid chess square!");
else
echo("Invalid chess square!");
// Checking multiple "to" squares
$square = "a1-a3,b2-b4, a4-b6 , h8-h2";
if (kpreg_is_valid_chess_squares($square,1,1,5)) // min 1 and max 5 'to' squares
echo("Valid chess square!");
else
echo("Invalid chess square!");
?>