function testok($a = '',$x,$y)
{
$a = explode(":",$a);
foreach($a as $an)
{
$an = explode(",",$an);
if($an[0] == $x)return false;
if($an[1] == $y)return false;
if(abs($x - $an[0]) == abs($y - $an[1]))return false;
}
return true;
}
function initData($x,$y,$number = array())
{
if(!$number)
{
$number = array("{$x},{$y}");
return initData($x,$y++,$number);
}
else
{
$y++;
$numbers = array();
foreach($number as $n)
{
for($i=1;$i<=8;$i++)
{
if(testok($n,$i,$y))
{
$numbers[] = $n.":{$i},{$y}";
}
}
}
if($y < 8)
{
return initData($x,$y++,$numbers);
}
else
{
return $numbers;
}
}
}
$rs = array();
for($x = 1;$x<=8;$x++)
{
$rs = array_merge($rs,initData($x,1));
}
print_r($rs);