/** * 二维数组排序 * @param array $array */ function sort_recursive(&$array){ foreach($array as $key=>$edge){ ksort($edge,true); $array[$key]=$edge; } ksort($array,true); } /** * 生成一圈环状数字 * @param array $cotainer 二维数组,包含生成的圈 * @param int $start_value 该圈的起始值 * @param int $x 该圈的偏移值 * @param int $grids_edge 每条边的数字个数 */ function generate(&$container,$start_value,$x,$grids_edge){ $rec_times=ceil($grids_edge/2); $center=$grids_edge&1?false:$start_value+4*$rec_times*($rec_times+1); if($center){ $index=$x+ceil($grids_edge/2); $container[$index][$index]=$center; } for($i=0;$iarray(1,6), 25=>array(2,4), 41=>array(3,2), ); /* $data=array( 1 =>array(1,2), ); $data=array( 1 =>array(1,5), 21=>array(2,3), 33=>array(3,1), ); $data=array( 1 =>array(1,3), 13=>array(2,1), ); */ foreach($data as $key=>$val){ generate($container,$key,$val[0],$val[1]); } sort_recursive($container); $table=''; foreach($container as $key=>$edge){ $table.=''; foreach($edge as $val){ $table.=''.$val.''; } $table.=''; } $table.=''; echo $table;
Statement
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks agoByDDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
3 weeks agoByDDD

Hot Tools

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version
Recommended: Win version, supports code prompts!
