CVS update: php3/doc/functions

From: Date: Mon, 26 Oct 1998 15:22:40 +0000
Subject: CVS update: php3/doc/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-2027@lists.php.net to get a copy of this message
Date: Monday October 26, 1998 @ 10:22 Author: ssb Update of /repository/php3/doc/functions In directory asf:/u2/tmp/cvs-serv24691 Modified Files: array.sgml Log Message: added uksort() Index: php3/doc/functions/array.sgml diff -c php3/doc/functions/array.sgml:1.25 php3/doc/functions/array.sgml:1.26 *** php3/doc/functions/array.sgml:1.25 Fri Sep 11 09:34:39 1998 --- php3/doc/functions/array.sgml Mon Oct 26 10:22:38 1998 *************** *** 665,674 **** </refsect1> </refentry> <refentry id="function.usort"> <refnamediv> <refname>usort</refname> ! <refpurpose>Sort an array using a user-define comparison function</refpurpose> </refnamediv> <refsect1> <title>Description</title> --- 665,717 ---- </refsect1> </refentry> + <refentry id="function.uksort"> + <refnamediv> + <refname>uksort</refname> + <refpurpose>Sort an array by keys using a user-defined comparison function</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcdef>void <function>uksort</function></funcdef> + <paramdef>array <parameter>array</parameter></paramdef> + <paramdef>function <parameter>cmp_function</parameter></paramdef> + </funcsynopsis> + <para> + This function will sort the keys of an array using a + user-supplied comparison function. If the array you wish to sort + needs to be sorted by some non-trivial criteria, you should use + this function. + <example> + <title><function>usort</function> example</title> + <programlisting> + function mycompare($a, $b) { + if ($a == $b) return 0; + return ($a > $b) ? -1 : 1; + } + $a = array(4 => "four", 3 => "three", 20 => "twenty", 10 => "ten"); + uksort($a, mycompare); + while(list($key, $value) = each($a)) { + echo "$key: $value\n"; + } + </programlisting></example> + This example would display: + <computeroutput> + 20: twenty + 10: ten + 4: four + 3: three + </computeroutput> + <para> + See also <function>arsort</function>, <function>asort</function>, + <function>ksort</function>, <function>rsort</function> and <function>sort</function>. + </refsect1> + </refentry> + <refentry id="function.usort"> <refnamediv> <refname>usort</refname> ! <refpurpose>Sort an array by values using a user-defined comparison function</refpurpose> </refnamediv> <refsect1> <title>Description</title> *************** *** 678,695 **** <paramdef>function <parameter>cmp_function</parameter></paramdef> </funcsynopsis> <para> ! This function will sort an array using a user-supplied comparison function. ! If the array you wish to sort needs to be sorted by some non-trivial ! criteria, you should use this function. <example> <title><function>usort</function> example</title> <programlisting> function cmp($a,$b) { ! if($a==$b) return 0; ! return ($a>$b) ? -1:1; } $a = array(3,2,5,6,1); ! usort($a,cmp); while(list($key,$value) = each($a)) { echo "$key: $value\n"; } --- 721,739 ---- <paramdef>function <parameter>cmp_function</parameter></paramdef> </funcsynopsis> <para> ! This function will sort an array by its values using a ! user-supplied comparison function. If the array you wish to sort ! needs to be sorted by some non-trivial criteria, you should use ! this function. <example> <title><function>usort</function> example</title> <programlisting> function cmp($a,$b) { ! if ($a == $b) return 0; ! return ($a > $b) ? -1 : 1; } $a = array(3,2,5,6,1); ! usort($a, cmp); while(list($key,$value) = each($a)) { echo "$key: $value\n"; } -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#2027) next »