<ol class="dp-c"> <li class="alt"><span><span class="comment">/**</span></span></li> <li><span><span class="comment"> * 2次元配列のソート </span></span></li> <li class="alt"><span><span class="comment"> * @param array $array </span></span></li> <li><span><span class="comment">*/</span><span> </span></span></li> <li class="alt"> <span class="keyword">function</span><span> sort_recursive(&</span><span class="vars">$array</span><span>){ </span> </li> <li> <span></span>foreach<span class="keyword"></span>(<span></span>$array<span class="vars"></span> <span></span>as<span class="keyword"></span> <span></span>$key<span class="vars"></span>=><span></span>$edge<span class="vars"></span>){ <span></span> </li> <li class="alt"> ksort(<span></span>$edge<span class="vars"></span>,true); <span></span> </li> <li> <span></span>$array<span class="vars"></span>[<span></span>$key<span class="vars"></span>]=<span></span>$edge<span class="vars"></span>; <span></span> </li> <li class="alt"> } <span></span> </li> <li> ksort(<span></span>$array<span class="vars"></span>,true); <span></span> </li> <li class="alt">} <span></span> </li> <li> <span></span> </li> <li class="alt">/**<span class="comment"></span> </li> <li><span> * 数値のリングを生成します <span class="comment"> </span></span></li> <li class="alt"><span> * @param array $cotainer 生成された円を含む 2 次元配列 <span class="comment"> </span></span></li> <li><span> * @param int $start_value の開始値Circle <span class="comment"></span></span></li> <li class="alt"><span> * @param int $x 円のオフセット値 <span class="comment"></span></span></li> <li><span> * @param int $grids_edge 各エッジの数値の数 <span class="comment"></span></span></li> <li class="alt"><span>*/<span class="comment"></span> <span></span></span></li> <li> generate(&<span class="keyword"></span>$containえー<span></span>、<span class="vars"></span>$start_value<span></span>、<span class="vars"></span> $x<span></span>,<span class="vars"></span>$grids_edge<span></span>){ <span class="vars"></span><span></span> </li> <li class="alt">$rec_times<span></span>=<span class="vars"></span>ceil<span></span>(<span class="func"></span>$grids_edge<span></span>/2 ); <span class="vars"></span><span></span> </li> <li>$center<span></span>=<span class="vars"></span>$grids_edge<span></span>&1?false:<span class="vars"></span>$start_value<span></span>+4*<span class="vars"></span>$rec_times<span></span>*(<span class="vars"></span> $rec_times<span></span>+1); <span class="vars"></span><span></span> </li> <li class="alt">if<span></span>(<span class="keyword"></span>$center<span></span>){ <span class="vars"></span><span></span> </li> <li>$index<span></span>=<span class="vars"></span>$x<span> </span>+<span class="vars"></span>ceil<span></span>(<span class="func"></span>$grids_edge<span></span>/2 ); <span class="vars"></span><span></span> </li> <li class="alt">$container<span></span>[<span class="vars"></span>$index<span></span>][<span class="vars"></span>$index<span></span>]=<span class="vars"></span>$center<span></span>; <span class="vars"></span><span></span> } </li> <li class="alt"> <span> </span><span class="keyword">for</span><span>(</span><span class="vars">$i</span><span>=0;</span><span class="vars">$i</span><span><</span><span class="vars">$grids_edge</span><span>;</span><span class="vars">$i</span><span>++) { </span></li><li><span> </span><span class="vars"> $right</span><span>=</span><span class="vars">$x</span><span>+</span><span class="vars">$grids_edge</span><span>; </span></li><li class="alt"><span> </span><span class="vars">$basevalue</span><span>=</span><span class="vars">$start_value</span><span>+</span><span class="vars">$i</span><span>; </span></li><li><span> </span><span class="vars">$container</span><span>[</span><span class="vars">$x</span><span>][</span><span class="vars">$x</span><span>+</span><span class="vars">$i</span><span>]=</span><span class="vars">$base_value</span> <span>; </span></li><li class="alt"><span> </span><span class="vars">$container</span><span>[</span><span class="vars">$x</span><span>+</span><span class="vars">$i</span><span>][</span><span class="vars">$right</span><span>]=</span><span class="vars">$grids_edge</span> <span>+</span><span class="vars">$base_value</span><span>; </span></li><li><span> </span><span class="vars">$container</span><span>[</span><span class="vars">$right</span><span>][</span><span class="vars">$right</span><span>-</span><span class="vars">$i</span><span>]=</span><span class="vars">$grids_edge </span><span>*2+</span><span class="vars">$base_value</span><span>; </span></li><li class="alt"><span> </span><span class="vars">$container</span><span>[</span><span class="vars">$right</span><span>-</span><span class="vars">$i</span><span>][</span><span class="vars">$x</span><span>]=</span><span class="vars">$grids_edge</span> <span>*3+</span><span class="vars">$base_value</span><span>; </span></li><li><span> } </span></li><li class="alt"><span>} </span></li><li><span> </span></li><li class="alt"><span> </span></li><li><span class="vars">$container</span><span>=</span> <span class="keyword">配列</span><span>(); </span></li><li class="alt"><span class="vars">$data</span><span>=</span><span class="keyword">array</span><span>( </span></li><li><span> 1 =></span><span class="keyword">array</span><span>(1,6), </span> </li> <li class="alt"> <span> 25=></span><span class="keyword">配列</span><span>(2, 4)、 </span> </li> <li> <span> 41=></span><span class="keyword">配列</span><span>(3,2), </span> </li> <li class="alt"><span>); </span></li> <li> <span class="comment">/*</span>$ data = array(</li> <li class="alt">1=&gt; array(1,2)、<span><span class="comment"></span></span> </li> <li>); <span> <span class="comment"></span></span> </li> <li class="alt">$data=array( <span> <span class="comment"></span></span> </li> <li> 1& <span> <span class="comment"></span></span>http://www.bkjia.com/PHPjc/486031.html</li> <li class="alt">www.bkjia.com<span><span class="comment">true<p align="left">http://www.bkjia.com/PHPjc/486031.html</p> <div style="display:none;"> <span id="url" itemprop="url">技術記事</span><span id="indexUrl" itemprop="indexUrl">例: $i=[数値]; 打印の通り下の図: 1 2 3 4 12 13 14 5 11 16 15 6 10 9 8 7 /***二次元配列のソート *@paramarray$array*/ function sort_recursive( $array ){ foreach ( $array...</span><span id="isOriginal" itemprop="isOriginal"></span><span id="isBasedOnUrl" itemprop="isBasedOnUrl"> </span><span id="genre" itemprop="genre"></span> </div></span></span> </li> </ol>