cvs: phpdoc-zh /reference/array/functions array-multisort.xml
| From: | Dallas Thunder | Date: | Thu, 19 Sep 2002 20:13:29 +0000 |
| Subject: | cvs: phpdoc-zh /reference/array/functions array-multisort.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-602@lists.php.net to get a copy of this message | ||
dallas Thu Sep 19 16:13:29 2002 EDT
Modified files:
/phpdoc-zh/reference/array/functions array-multisort.xml
Log:
Done.
Index: phpdoc-zh/reference/array/functions/array-multisort.xml
diff -u phpdoc-zh/reference/array/functions/array-multisort.xml:1.1
phpdoc-zh/reference/array/functions/array-multisort.xml:1.2
--- phpdoc-zh/reference/array/functions/array-multisort.xml:1.1 Wed Sep 11 14:06:57 2002
+++ phpdoc-zh/reference/array/functions/array-multisort.xml Thu Sep 19 16:13:29 2002
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="gb2312"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<!-- $Author: dallas $ -->
<!-- EN-Revision: 1.4 Maintainer: dallas Status: ready -->
<refentry id="function.array-multisort">
@@ -20,57 +20,47 @@
<function>array_multisort</function>
¿ÉÒÔÓÃÀ´Ò»´Î¶Ô¶à¸öÊý×é½øÐÐÅÅÐò»òÕ߸ù¾Ýijһά¶Ô¶àάÊý×é½øÐÐÅÅÐò¡£ÅÅÐòʱ±£ÁôÔÓеļüÃû¹ØÁª¡£
</para>
<para>
- ÊäÈëÊý×é±»µ±³ÉÒ»¸ö½«ÒÔÐÐÀ´ÅÅÐòµÄ±íµÄÁÐ £
ÕâÀàËÆÓÚ SQL µÄ ORDER BY
- ×Ó¾äµÄ¹¦ÄÜ¡£µÚÒ»¸öÊý×éÊÇÒªÅÅÐòµÄÖ÷ÒªÊý×é¡£
- The input arrays are treated as columns of a table to be sorted
- by rows - this resembles the functionality of SQL ORDER BY
- clause. The first array is the primary one to sort by. The rows
- (values) in that array that compare the same are sorted by the
- next input array, and so on.
- </para>
- <para>
- The argument structure of this function is a bit unusual, but
- flexible. The very first argument has to be an
- array. Subsequently, each argument can be either an array or a
- sorting flag from the following lists.
+ ÊäÈëÊý×é±»µ±³ÉÒ»¸ö±íµÄÁв¢ÒÔÐÐÀ´ÅÅÐò £ ÕâÀàËÆÓÚ
SQL µÄ ORDER BY
+
×Ó¾äµÄ¹¦ÄÜ¡£µÚÒ»¸öÊý×éÊÇÒªÅÅÐòµÄÖ÷ÒªÊý×é¡£Êý×éÖеÄÐУ¨Öµ£©±È½ÏΪÏàͬµÄ»°¾Í°´ÕÕÏÂÒ»¸öÊäÈëÊý×éÖÐÏàÓ¦ÖµµÄ´óСÀ´ÅÅÐò£¬ÒÀ´ËÀàÍÆ¡£
</para>
<para>
- Sorting order flags:
+
±¾º¯ÊýµÄ²ÎÊý½á¹¹ÓÐЩ²»Í¬Ñ°³££¬µ«ÊǷdz£Áé»î¡£µÚÒ»¸ö²ÎÊý±ØÐëÊÇÒ»¸öÊý×é¡£½ÓÏÂÀ´µÄÿ¸ö²ÎÊý¿ÉÒÔÊÇÊý×é»òÕßÊÇÏÂÃæÁгöµÄÅÅÐò±êÖ¾¡£
+ </para>
+ <para>
+ ÅÅÐò˳Ðò±êÖ¾£º
<itemizedlist>
<listitem>
- <simpara>SORT_ASC - sort in ascending order</simpara>
+ <simpara>SORT_ASC - °´ÕÕÉÏÉý˳ÐòÅÅÐò</simpara>
</listitem>
<listitem>
- <simpara>SORT_DESC - sort in descending order</simpara>
+ <simpara>SORT_DESC - °´ÕÕϽµË³ÐòÅÅÐò</simpara>
</listitem>
</itemizedlist>
</para>
<para>
- Sorting type flags:
+ ÅÅÐòÀàÐͱêÖ¾£º
<itemizedlist>
<listitem>
- <simpara>SORT_REGULAR - compare items normally</simpara>
+ <simpara>SORT_REGULAR - ½«ÏîÄ¿°´ÕÕͨ³£·½·¨±È½Ï</simpara>
</listitem>
<listitem>
- <simpara>SORT_NUMERIC - compare items numerically</simpara>
+ <simpara>SORT_NUMERIC - ½«ÏîÄ¿°´ÕÕÊýÖµ±È½Ï</simpara>
</listitem>
<listitem>
- <simpara>SORT_STRING - compare items as strings</simpara>
+ <simpara>SORT_STRING - ½«ÏîÄ¿°´ÕÕ×Ö·û´®±È½Ï</simpara>
</listitem>
</itemizedlist>
</para>
<para>
- No two sorting flags of the same type can be specified after each
- array. The sorting flags specified after an array argument apply
- only to that array - they are reset to default SORT_ASC and
- SORT_REGULAR after before each new array argument.
+
ÿ¸öÊý×éÖ®ºó²»ÄÜÖ¸¶¨Á½¸öͬÀàµÄÅÅÐò±êÖ¾¡£Ã¿¸öÊý×éºóÖ¸¶¨µÄÅÅÐò±êÖ¾½ö¶Ô¸ÃÊý×éÓÐЧ£¬Ä¬ÈÏֵΪ
+ SORT_ASC ºÍ SORT_REGULAR¡£
</para>
<para>
&return.success;
</para>
<para>
<example>
- <title>Sorting multiple arrays</title>
+ <title>¶Ô¶à¸öÊý×éÅÅÐò</title>
<programlisting role="php">
<![CDATA[
$ar1 = array ("10", 100, 100, "a");
@@ -81,14 +71,13 @@
</example>
</para>
<para>
- In this example, after sorting, the first array will contain 10,
- "a", 100, 100. The second array will contain 1, 1, "2", 3. The
- entries in the second array corresponding to the identical
- entries in the first array (100 and 100) were sorted as well.
+ ±¾ÀýÖо¹ýÅÅÐòºó£¬µÚÒ»¸öÊý×齫°üº¬
+ 10£¬"a"£¬100£¬100¡£µÚ¶þ¸öÊý×齫°üº¬
+
1£¬1£¬"2"£¬3¡£µÚ¶þ¸öÊý×éÖеÄÏîĿ˳ÐòÍêÈ«ºÍµÚÒ»¸öÊý×éÖÐÏàÓ¦µÄÏîÄ¿£¨100
ºÍ 100£©Ë³ÐòÒ»Ö¡£
</para>
<para>
<example>
- <title>Sorting multi-dimensional array</title>
+ <title>¶Ô¶àάÊý×éÅÅÐò</title>
<programlisting role="php">
<![CDATA[
$ar = array (array ("10", 100, 100, "a"), array (1, 3, "2", 1));
@@ -99,10 +88,44 @@
</example>
</para>
<para>
- In this example, after sorting, the first array will contain 10,
- 100, 100, "a" (it was sorted as strings in ascending order), and
- the second one will contain 1, 3, "2", 1 (sorted as numbers, in
- descending order).
+ ±¾ÀýÖо¹ýÅÅÐòºó£¬µÚÒ»¸öÊý×齫°üº¬
+
10£¬100£¬100£¬"a"£¨×÷Ϊ×Ö·û´®ÉÏÉýÅÅÐò£©£¬µÚ¶þ¸öÊý×齫°üº¬
+ 1£¬3£¬"2"£¬1£¨×÷ΪÊýֵϽµÅÅÐò£©¡£
+ </para>
+ <para>
+
¡¾ÒëÕß×¢¡¿±¾º¯ÊýÏ൱·Ñ½â£¬ÎªÓÐÖúÓÚÀí½â£¬ÇëÔÙ¿´ÏÂÃæÁ½¸öÀý×Ó£º
+ <example>
+ <title>Êý×éÅÅÐò</title>
+ <programlisting role="php">
+<![CDATA[
+$ar1 = array ("200", 100.0, 400, "300");
+$ar2 = array ( 3, 1, "4", 2);
+array_multisort ($ar1, $ar2);
+// ÅÅÐòºóµÄ½á¹ûÊÇ£º
+// $ar1 = array (100.0, "200", "300", 400);
+// $ar2 = array ( 1, 3, 2, "4");
+
+$ar1 = array ("100", 100.0, 100, "100");
+$ar2 = array ( 3, 1, "4", 2);
+array_multisort ($ar1, $ar2);
+// ÅÅÐòºóµÄ½á¹ûÊÇ£º
+// $ar1 = array (100.0, "100", "100", 100);
+// $ar2 = array ( 1, 2, 3, "4");
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
+ ǰһ¸öÀý×ÓÖжÔ
+ <literal>$ar1</literal>
µÄÅÅÐòµ±ÎÞÒìÒ飬°´ÕÕĬÈϵÄÅÅÐò±êÖ¾´ÓСµ½´óÅÅÁкã¬Í¬Ê±
+ <literal>$ar2</literal> ÖкÍ
+ <literal>$ar1</literal> Ïà¶ÔÓ¦µÄµ¥ÔªÒ²ÍêÈ«°´ÕÕ
+ <literal>$ar1</literal>
µÄ˳ÐòÅÅÁÐÁË¡£µ«ÊǺóÒ»¸öÀý×ÓÖÐÎÞÂÛºÎÖÖÓÃÅÅÐò±êÖ¾
+ <literal>$ar1</literal> Öеĵ¥Ôª¶¼±È½Ï²»³ö˳Ðò£¬Õâʱ
+ <literal>$ar1</literal> Öеĵ¥Ôª¾Í»á°´ÕÕ
+ <literal>$ar2</literal>
Öеĵ¥ÔªÅÅÐò½á¹ûÀ´ÅÅÐò¡£¿ÉÒÔÓÃ
+ <function>var_dump</function> º¯ÊýÀ´²é¿´
+ <literal>$ar1</literal> Öе¥ÔªµÄ˳Ðò¡£
</para>
</refsect1>
</refentry>