mirror of
https://github.com/php/doc-ja.git
synced 2026-04-26 01:18:04 +02:00
f98d10d652
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@189687 c90b9560-bf6c-de11-be94-00142212c4b1
100 lines
2.7 KiB
XML
100 lines
2.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 1.7 $ -->
|
|
<!-- EN-Revision: 1.16 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka -->
|
|
<refentry id="function.uksort">
|
|
<refnamediv>
|
|
<refname>uksort</refname>
|
|
<refpurpose>
|
|
ユーザー定義の比較関数を用いてキーで配列をソートします
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>説明</title>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>uksort</methodname>
|
|
<methodparam><type>array</type><parameter role="reference">array</parameter></methodparam>
|
|
<methodparam><type>callback</type><parameter>cmp_function</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>uksort</function> は、
|
|
ユーザー定義の比較関数を用いて配列のキーをソートします。
|
|
ソートしたい配列を複雑な基準でソートする必要がある場合には、
|
|
この関数を使う必要があります。
|
|
</para>
|
|
<para>
|
|
関数 <parameter>cmp_function</parameter> は、
|
|
<parameter>array</parameter> のキーペアによって満たされる
|
|
2 つのパラメータを受け取ります。
|
|
第 1 引数が第 2 引数と等しいあるいは大きいと見なさない場合、
|
|
この比較関数は、0 に等しいあるいはそれより大きな整数を返してはなりません。
|
|
</para>
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>uksort</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
function cmp($a, $b)
|
|
{
|
|
if ($a == $b) {
|
|
return 0;
|
|
}
|
|
return ($a > $b) ? -1 : 1;
|
|
}
|
|
|
|
$a = array(4 => "four", 3 => "three", 20 => "twenty", 10 => "ten");
|
|
|
|
uksort($a, "cmp");
|
|
|
|
foreach ($a as $key => $value) {
|
|
echo "$key: $value\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
20: twenty
|
|
10: ten
|
|
4: four
|
|
3: three
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<function>usort</function>, <function>uasort</function>,
|
|
<function>sort</function>, <function>asort</function>,
|
|
<function>arsort</function>, <function>ksort</function>,
|
|
<function>natsort</function>, <function>rsort</function>
|
|
も参照ください。
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|