sort(): 配列要素を下位から上位に並べ替えるだけです。この関数は数値順またはアルファベット順に並べることができます。
<code>Listing A <span><?php</span><span>$data</span> = <span>array</span>(<span>5</span>,<span>8</span>,<span>1</span>,<span>7</span>,<span>2</span>); sort(<span>$data</span>); print_r(<span>$data</span>); <span>?></span>输出结果如下所示: <span>Array</span> ([<span>0</span>] => <span>1</span>[<span>1</span>] => <span>2</span>[<span>2</span>] => <span>5</span>[<span>3</span>] => <span>7</span>[<span>4</span>] => <span>8</span>)</code>
rsort(): 配列要素を数値順またはアルファベット順に高い順に並べ替えます。
<code><span><?php</span><span>$data</span> = <span>array</span>(<span>5</span>,<span>8</span>,<span>1</span>,<span>7</span>,<span>2</span>);rsort(<span>$data</span>); print_r(<span>$data</span>); <span>?></span>它的输出结果如下: <span>Array</span> ([<span>0</span>] => <span>8</span>[<span>1</span>] => <span>7</span>[<span>2</span>] => <span>5</span>[<span>3</span>] => <span>2</span>[<span>4</span>] => <span>1</span>)</code>
ksort(): キーワードに従って並べ替える関数。同時に、並べ替えプロセス中にキーワードの関連性を維持します。
<code><span><?php</span><span>$data</span> = <span>array</span>(<span>"US"</span> => <span>"United States"</span>, <span>"IN"</span> => <span>"India"</span>, <span>"DE"</span> => <span>"Germany"</span>, <span>"ES"</span> => <span>"Spain"</span>); ksort(<span>$data</span>); print_r(<span>$data</span>); <span>?></span>它的输出结果如下: <span>Array</span> ([DE] => Germany [ES] => Spain [IN] => India [US] => United States )</span></code>
krsort(): キーワードに従って配列を反転します。
<code><span><?php</span><span>$data</span> = <span>array</span>(<span>"US"</span> => <span>"United States"</span>, <span>"IN"</span> => <span>"India"</span>, <span>"DE"</span> => <span>"Germany"</span>, <span>"ES"</span> => <span>"Spain"</span>); krsort(<span>$data</span>); print_r(<span>$data</span>); <span>?></span>它的输出结果如下: <span>Array</span> ([US] => United States [IN] => India [ES] => Spain [DE] => Germany )</span></code>
asort(): キーワードの並べ替えではなく値の並べ替えを使用します。キーワードと値の関係は常に維持されることに注意してください。
<code><span><?php</span><span>$data</span> = <span>array</span>(<span>"US"</span> => <span>"United States"</span>, <span>"IN"</span> => <span>"India"</span>, <span>"DE"</span> => <span>"Germany"</span>, <span>"ES"</span> => <span>"Spain"</span>); asort(<span>$data</span>); print_r(<span>$data</span>); <span>?></span>它的输出结果如下: <span>Array</span> ([DE] => Germany [IN] => India [ES] => Spain [US] => United States )</span></code>
arsort(): 値のアルファベット順に並べ替えます。
<code><span><?php</span><span>$data</span> = <span>array</span>(<span>"US"</span> => <span>"United States"</span>, <span>"IN"</span> => <span>"India"</span>, <span>"DE"</span> => <span>"Germany"</span>, <span>"ES"</span> => <span>"Spain"</span>); arsort(<span>$data</span>); print_r(<span>$data</span>); <span>?></span><span>Array</span> ([US] => United States [ES] => Spain [IN] => India [DE] => Germany )</span></code>').addClass('事前番号付け').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
上記は、PHP のソート機能を関連コンテンツも含めて紹介しました。PHP チュートリアルに興味のある友人に役立つことを願っています。