Home > Backend Development > PHP Tutorial > 用php数字九宫格.

用php数字九宫格.

WBOY
Release: 2016-06-23 13:59:20
Original
1601 people have browsed it

如下,效果:
2 3 4 5 6 7 8 9 1
3 4 5 6 7 8 9 1 2
4 5 6 7 8 9 1 2 3
5 6 7 8 9 1 2 3 4
6 7 8 9 1 2 3 4 5
7 8 9 1 2 3 4 5 6
8 9 1 2 3 4 5 6 7
9 1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9 


回复讨论(解决方案)

$arr1 = array('1','2','3','4','5','6','7','8','9');for($i=0;$i<count($arr1);$i++){	array_push($arr1,array_shift($arr1));	echo join(' ',$arr1)."<br />";}
Copy after login
Copy after login

$start = 1;$arr = array(1, 2, 3, 4, 5, 6, 7, 8, 9);$length = count($arr);for($stepX=0;$stepX<$length;$stepX++){	for($stepY=0;$stepY<$length;$stepY++){		echo $arr[($stepX+$stepY+$start)%$length].' ';	}	echo '<br/>';}
Copy after login

求蹭分。

如下,效果:
2 3 4 5 6 7 8 9 1
3 4 5 6 7 8 9 1 2
4 5 6 7 8 9 1 2 3
5 6 7 8 9 1 2 3 4
6 7 8 9 1 2 3 4 5
7 8 9 1 2 3 4 5 6
8 9 1 2 3 4 5 6 7
9 1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9

$arr1 = array('1','2','3','4','5','6','7','8','9');for($i=0;$i<count($arr1);$i++){	array_push($arr1,array_shift($arr1));	echo join(' ',$arr1)."<br />";}
Copy after login
Copy after login


上一条发错了,不好意思。

<?phpfor($i=0; $i<81; $i++){	$tmp = $i%9+floor($i/9)+2;	if($tmp>=10){		$tmp = $tmp%10+1;	}	printf("%3d", $tmp);	if(($i+1)%9==0){		echo '<br>';	}}?>
Copy after login

你这是什么?
九宫格是3x3矩阵(填写1-9个数)
数独是9个九宫格的组合

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template