cvs: phpdoc-zh /reference/array/functions array-pad.xml array-pop.xml array-push.xml array-rand.xml array-reduce.xml array-reverse.xml
array-search.xml array-shift.xml array-slice.xml
| From: | Dallas Thunder | Date: | Mon, 09 Sep 2002 21:00:25 +0000 |
| Subject: | cvs: phpdoc-zh /reference/array/functions array-pad.xml array-pop.xml array-push.xml array-rand.xml array-reduce.xml array-reverse.xml array-search.xml array-shift.xml array-slice.xml |
||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-487@lists.php.net to get a copy of this message | ||
dallas Mon Sep 9 17:00:25 2002 EDT
Added files:
/phpdoc-zh/reference/array/functions array-pad.xml array-pop.xml
array-push.xml array-rand.xml
array-reduce.xml
array-reverse.xml
array-search.xml
array-shift.xml
array-slice.xml
Log:
Translation completed.
Index: phpdoc-zh/reference/array/functions/array-pad.xml +++ phpdoc-zh/reference/array/functions/array-pad.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-pad"> <refnamediv> <refname>array_pad</refname> <refpurpose> ÓÃÖµ½«Êý×éÌî²¹µ½Ö¸¶¨³¤¶È </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>array</type><methodname>array_pad</methodname> <methodparam><type>array</type><parameter>input</parameter></methodparam> <methodparam><type>int</type><parameter>pad_size</parameter></methodparam> <methodparam><type>mixed</type><parameter>pad_value</parameter></methodparam> </methodsynopsis> <para> <function>array_pad</function> ·µ»Ø <parameter>input</parameter> µÄÒ»¸ö¿½±´£¬²¢Óà <parameter>pad_value</parameter> ½«ÆäÌî²¹µ½ <parameter>pad_size</parameter> Ö¸¶¨µÄ³¤¶È¡£Èç¹û <parameter>pad_size</parameter> ΪÕý£¬ÔòÊý×é±»Ìî²¹µ½ÓҲ࣬Èç¹ûΪ¸ºÔò´Ó×ó²à¿ªÊ¼Ìî²¹¡£Èç¹û <parameter>pad_size</parameter> µÄ¾ø¶ÔֵСÓÚ»òµÈÓÚ <parameter>input</parameter> Êý×éµÄ³¤¶ÈÔòûÓÐÈκÎÌî²¹¡£ </para> <para> <example> <title><function>array_pad</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $input = array (12, 10, 9); $result = array_pad ($input, 5, 0); // result is array (12, 10, 9, 0, 0) $result = array_pad ($input, -7, -1); // result is array (-1, -1, -1, -1, 12, 10, 9) $result = array_pad ($input, 2, "noop"); // not padded ]]> </programlisting> </example> </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 --> Index: phpdoc-zh/reference/array/functions/array-pop.xml +++ phpdoc-zh/reference/array/functions/array-pop.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-pop"> <refnamediv> <refname>array_pop</refname> <refpurpose>½«Êý×é×îºóÒ»¸öµ¥Ôªµ¯³ö£¨³öÕ»£©</refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>mixed</type><methodname>array_pop</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> </methodsynopsis> <para> <function>array_pop</function> µ¯³ö²¢·µ»Ø <parameter>array</parameter> Êý×éµÄ×îºóÒ»¸öµ¥Ôª£¬²¢½«Êý×é <parameter>array</parameter> µÄ³¤¶È¼õÒ»¡£Èç¹û <parameter>array</parameter> Ϊ¿Õ£¨»òÕß²»ÊÇÊý×飩½«·µ»Ø &null;¡£ </para> <para> <example> <title><function>array_pop</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $stack = array ("orange", "banana", "apple", "raspberry"); $fruit = array_pop ($stack); ]]> </programlisting> <para> ¾¹ý´Ë²Ù×÷ºó£¬<varname>$stack</varname> ½«Ö»ÓÐ 3 ¸öµ¥Ôª£º <screen role="php"> <![CDATA[ Array ( [0] => orange [1] => banana [2] => apple ) ]]> </screen> ²¢ÇÒ <literal>rasberry</literal> ½«±»¸³¸ø <varname>$fruit</varname>¡£ </para> </example> </para> &return.falseproblem; <para> ²Î¼û <function>array_push</function>£¬<function>array_shift</function> ºÍ <function>array_unshift</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 --> Index: phpdoc-zh/reference/array/functions/array-push.xml +++ phpdoc-zh/reference/array/functions/array-push.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-push"> <refnamediv> <refname>array_push</refname> <refpurpose> ½«Ò»¸ö»ò¶à¸öµ¥ÔªÑ¹ÈëÊý×éµÄĩ⣨ÈëÕ»£© </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>int</type><methodname>array_push</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> <methodparam><type>mixed</type><parameter>var</parameter></methodparam> <methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam> </methodsynopsis> <para> <function>array_push</function> ½« <parameter>array</parameter> µ±³ÉÒ»¸öÕ»£¬²¢½«´«ÈëµÄ±äÁ¿Ñ¹Èë <parameter>array</parameter> µÄĩβ¡£ <parameter>array</parameter> µÄ³¤¶È½«Ôö¼ÓÈëÕ»±äÁ¿µÄÊýÄ¿¡£ºÍÈçÏÂЧ¹ûÏàͬ£º <programlisting role="php"> <![CDATA[ $array[] = $var; ]]> </programlisting> ²¢¶Ôÿ¸ö <parameter>var</parameter> ÖØ¸´ÒÔÉ϶¯×÷¡£ </para> <para> ·µ»ØÊý×éеĵ¥Ôª×ÜÊý¡£ </para> <para> <example> <title><function>array_push</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $stack = array ("orange", "banana"); array_push ($stack, "apple", "raspberry"); ]]> </programlisting> <para> ±¾Àý½«Ê¹ <varname>$stack</varname> ¾ßÓÐÈçϵ¥Ôª£º <screen role="php"> <![CDATA[ Array ( [0] => orange [1] => banana [2] => apple [3] => raspberry ) ]]> </screen> </para> </example> </para> <para> ²Î¼û <function>array_pop</function>£¬<function>array_shift</function> ºÍ <function>array_unshift</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 --> Index: phpdoc-zh/reference/array/functions/array-rand.xml +++ phpdoc-zh/reference/array/functions/array-rand.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-rand"> <refnamediv> <refname>array_rand</refname> <refpurpose> ´ÓÊý×éÖÐËæ»úÈ¡³öÒ»¸ö»ò¶à¸öµ¥Ôª </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>mixed</type><methodname>array_rand</methodname> <methodparam><type>array</type><parameter>input</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>num_req</parameter></methodparam> </methodsynopsis> <para> <function>array_rand</function> ÔÚÄãÏë´ÓÊý×éÖÐÈ¡³öÒ»¸ö»ò¶à¸öËæ»úµÄµ¥ÔªÊ±Ï൱ÓÐÓá£Ëü½ÓÊÜ <parameter>input</parameter> ×÷ΪÊäÈëÊý×éºÍÒ»¸ö¿ÉÑ¡µÄ²ÎÊý <parameter>num_req</parameter>£¬Ö¸Ã÷ÁËÄãÏëÈ¡³ö¶àÉÙ¸öµ¥Ôª £ Èç¹ûûÓÐÖ¸¶¨£¬Ä¬ÈÏΪ 1¡£ </para> <para> Èç¹ûÄãֻȡ³öÒ»¸ö£¬<function>array_rand</function> ·µ»ØÒ»¸öËæ»úµ¥ÔªµÄ¼üÃû¡£·ñÔò¾Í·µ»ØÒ»¸ö°üº¬Ëæ»ú¼üÃûµÄÊý×é¡£ÕâÑùÄã¾Í¿ÉÒÔËæ»ú´ÓÊý×éÖÐÈ¡³ö¼üÃûºÍÖµ¡£ </para> <para> ²»ÒªÍü¼Çµ÷Óà <function>srand</function> À´ÈöÏÂËæ»úÊý·¢ÉúÆ÷µÄÖÖ×Ó¡£ </para> <para> <example> <title><function>array_rand</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ srand ((float) microtime() * 10000000); $input = array ("Neo", "Morpheus", "Trinity", "Cypher", "Tank"); $rand_keys = array_rand ($input, 2); print $input[$rand_keys[0]]."\n"; print $input[$rand_keys[1]]."\n"; ]]> </programlisting> </example> </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 --> Index: phpdoc-zh/reference/array/functions/array-reduce.xml +++ phpdoc-zh/reference/array/functions/array-reduce.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-reduce"> <refnamediv> <refname>array_reduce</refname> <refpurpose> Óûص÷º¯Êýµü´úµØ½«Êý×é¼ò»¯Îªµ¥Ò»µÄÖµ function </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>mixed</type><methodname>array_reduce</methodname> <methodparam><type>array</type><parameter>input</parameter></methodparam> <methodparam><type>mixed</type><parameter>callback</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>initial</parameter></methodparam> </methodsynopsis> <para> <function>array_reduce</function> ½«»Øµ÷º¯Êý <parameter>callback</parameter> µü´úµØ×÷Óõ½ <parameter>input</parameter> Êý×éÖеÄÿһ¸öµ¥ÔªÖУ¬´Ó¶ø½«Êý×é¼ò»¯Îªµ¥Ò»µÄÖµ¡£Èç¹ûÖ¸¶¨ÁË¿ÉÑ¡²ÎÊý <parameter>initial</parameter>£¬¸Ã²ÎÊý½«±»µ±³ÉÊÇÊý×éÖеĵÚÒ»¸öÖµÀ´´¦Àí£¬»òÕßÈç¹ûÊý×éΪ¿ÕµÄ»°¾Í×÷Ϊ×îÖÕ·µ»ØÖµ¡£ </para> <para> <example> <title><function>array_reduce</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ function rsum($v, $w) { $v += $w; return $v; } function rmul($v, $w) { $v *= $w; return $v; } $a = array(1, 2, 3, 4, 5); $x = array(); $b = array_reduce($a, "rsum"); $c = array_reduce($a, "rmul", 10); $d = array_reduce($x, "rsum", 1); ]]> </programlisting> </example> </para> <para> Õ⽫ʹ <varname>$b</varname> µÄֵΪ <literal>15</literal>£¬<varname>$c</varname> µÄֵΪ <literal>1200</literal>£¨= 1*2*3*4*5*10£©£¬ÒÔ¼° <varname>$d</varname> µÄֵΪ <literal>1</literal>¡£ </para> <para> ²Î¼û <function>array_filter</function> ºÍ <function>array_map</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 --> Index: phpdoc-zh/reference/array/functions/array-reverse.xml +++ phpdoc-zh/reference/array/functions/array-reverse.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-reverse"> <refnamediv> <refname>array_reverse</refname> <refpurpose> ·µ»ØÒ»¸ö½«µ¥Ôª·´ÐòµÄÊý×é </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>array</type><methodname>array_reverse</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> <methodparam choice="opt"><type>bool</type><parameter>preserve_keys</parameter></methodparam> </methodsynopsis> <para> <function>array_reverse</function> ½ÓÊÜÊý×é <parameter>array</parameter> ×÷ΪÊäÈë²¢·µ»ØÒ»¸öµ¥ÔªÎªÏ෴˳ÐòµÄÐÂÊý×飬Èç¹û <parameter>preserve_keys</parameter> Ϊ &true; Ôò±£ÁôÔÀ´µÄ¼üÃû¡£ </para> <para> <example> <title><function>array_reverse</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $input = array ("php", 4.0, array ("green", "red")); $result = array_reverse ($input); $result_keyed = array_reverse ($input, TRUE); ]]> </programlisting> <para> Õ⽫ʹ <varname>$result</varname> ºÍ <varname>$result_keyed</varname> ¾ßÓÐÏàͬµÄµ¥Ôª£¬µ«ÊÇ×¢Òâ¼üÃûµÄÇø±ð¡£<varname>$result</varname> ºÍ <varname>$result_keyed</varname> µÄ´òÓ¡Êä³öÏÔʾ·Ö±ðΪ£º <screen role="php"> <![CDATA[ Array ( [0] => Array ( [0] => green [1] => red ) [1] => 4 [2] => php ) Array ( [2] => Array ( [0] => green [1] => red ) [1] => 4 [0] => php ) ]]> </screen> </para> </example> </para> <note> <para> µÚ¶þ¸ö²ÎÊýÊÇ PHP 4.0.3 ÖÐмӵġ£ </para> </note> </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 --> Index: phpdoc-zh/reference/array/functions/array-search.xml +++ phpdoc-zh/reference/array/functions/array-search.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-search"> <refnamediv> <refname>array_search</refname> <refpurpose> ÔÚÊý×éÖÐËÑË÷¸ø¶¨µÄÖµ£¬Èç¹û³É¹¦Ôò·µ»ØÏàÓ¦µÄ¼üÃû </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>mixed</type><methodname>array_search</methodname> <methodparam><type>mixed</type><parameter>needle</parameter></methodparam> <methodparam><type>array</type><parameter>haystack</parameter></methodparam> <methodparam choice="opt"><type>bool</type><parameter>strict</parameter></methodparam> </methodsynopsis> <para> ÔÚ <parameter>haystack</parameter> ÖÐËÑË÷ <parameter>needle</parameter> ²ÎÊý²¢ÔÚÕÒµ½µÄÇé¿öÏ·µ»Ø¼üÃû£¬·ñÔò·µ»Ø &false;¡£ </para> <note> <para> ÔÚ PHP 4.2.0 ֮ǰ£¬<function>array_search</function> ÔÚʧ°Üʱ·µ»Ø <constant>NULL</constant> ¶ø²»ÊÇ &false;¡£ </para> </note> <para> Èç¹û¿ÉÑ¡µÄµÚÈý¸ö²ÎÊý <parameter>strict</parameter> Ϊ &true;£¬Ôò <function>array_search</function> »¹½«ÔÚ <parameter>haystack</parameter> Öмì²é <parameter>needle</parameter> µÄÀàÐÍ¡£ </para> &return.falseproblem; <para> ²Î¼û <function>array_keys</function> ºÍ <function>in_array</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 --> Index: phpdoc-zh/reference/array/functions/array-shift.xml +++ phpdoc-zh/reference/array/functions/array-shift.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.5 Maintainer: dallas Status: ready --> <refentry id="function.array-shift"> <refnamediv> <refname>array_shift</refname> <refpurpose> ½«Êý×鿪ͷµÄµ¥ÔªÒƳöÊý×é </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>mixed</type><methodname>array_shift</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> </methodsynopsis> <para> <function>array_shift</function> ½« <parameter>array</parameter> µÄµÚÒ»¸öµ¥ÔªÒƳö²¢×÷Ϊ½á¹û·µ»Ø£¬½« <parameter>array</parameter> µÄ³¤¶È¼õÒ»²¢½«ËùÓÐÆäËüµ¥ÔªÏòÇ°ÒÆ¶¯Ò»Î»¡£ËùÓеÄÊý×Ö¼üÃû½«¸ÄΪ´ÓÁ㿪ʼ¼ÆÊý£¬ÎÄ×Ö¼üÃû½«²»±ä¡£Èç¹û <parameter>array</parameter> Ϊ¿Õ£¨»òÕß²»ÊÇÊý×飩£¬Ôò·µ»Ø &null;¡£ </para> <para> <example> <title><function>array_shift</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $stack = array ("orange", "banana", "apple", "raspberry"); $fruit = array_shift ($stack); ]]> </programlisting> <para> Õ⽫ʹ <varname>$stack</varname> ʣϠ3 ¸öµ¥Ôª£º <screen role="php"> <![CDATA[ Array ( [0] => banana [1] => apple [2] => raspberry ) ]]> </screen> ²¢ÇÒ <literal>orange</literal> ±»¸³¸øÁË <varname>$fruit</varname>¡£ </para> </example> </para> <para> ²Î¼û <function>array_unshift</function>£¬<function>array_push</function> ºÍ <function>array_pop</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 --> Index: phpdoc-zh/reference/array/functions/array-slice.xml +++ phpdoc-zh/reference/array/functions/array-slice.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-slice"> <refnamediv> <refname>array_slice</refname> <refpurpose>´ÓÊý×éÖÐÈ¡³öÒ»¶Î</refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>array</type><methodname>array_slice</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> <methodparam><type>int</type><parameter>offset</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter> length </parameter></methodparam> </methodsynopsis> <para> <function>array_slice</function> ·µ»Ø¸ù¾Ý <parameter>offset</parameter> ºÍ <parameter>length</parameter> ²ÎÊýËùÖ¸¶¨µÄ <parameter>array</parameter> Êý×éÖеÄÒ»¶ÎÐòÁС£ </para> <para> Èç¹û <parameter>offset</parameter> ΪÕý£¬ÔòÐòÁн«´Ó <parameter>array</parameter> ÖÐµÄ´ËÆ«ÒÆÁ¿¿ªÊ¼¡£Èç¹û <parameter>offset</parameter> Ϊ¸º£¬ÔòÐòÁн«´Ó <parameter>array</parameter> ÖоàÀëÄ©¶ËÕâôԶµÄµØ·½¿ªÊ¼¡£ </para> <para> Èç¹û¸ø³öÁË <parameter>length</parameter> ²¢ÇÒΪÕý£¬ÔòÐòÁÐÖн«¾ßÓÐÕâô¶àµÄµ¥Ôª¡£Èç¹û¸ø³öÁË <parameter>length</parameter> ²¢ÇÒΪ¸º£¬ÔòÐòÁн«ÖÕÖ¹ÔÚ¾àÀëÊý×éÄ©¶ËÕâôԶµÄµØ·½¡£Èç¹ûÊ¡ÂÔ£¬ÔòÐòÁн«´Ó <parameter>offset</parameter> ¿ªÊ¼Ò»Ö±µ½ <parameter>array</parameter> µÄÄ©¶Ë¡£ </para> <para> ×¢Òâ <function>array_slice</function> ½«ºöÂÔ¼üÃû£¬²¢ÇÒÊǸù¾Ýµ¥ÔªÔÚÊý×éÖеÄʵ¼ÊλÖÃÀ´¼ÆËãÆ«ÒÆÁ¿ºÍ³¤¶ÈµÄ¡£ </para> <para> <example> <title><function>array_slice</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $input = array ("a", "b", "c", "d", "e"); $output = array_slice ($input, 2); // returns "c", "d", and "e" $output = array_slice ($input, 2, -1); // returns "c", "d" $output = array_slice ($input, -2, 1); // returns "d" $output = array_slice ($input, 0, 3); // returns "a", "b", and "c" ]]> </programlisting> </example> </para> <para> ²Î¼û <function>array_splice</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 -->
Index: phpdoc-zh/reference/array/functions/array-pad.xml +++ phpdoc-zh/reference/array/functions/array-pad.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-pad"> <refnamediv> <refname>array_pad</refname> <refpurpose> ÓÃÖµ½«Êý×éÌî²¹µ½Ö¸¶¨³¤¶È </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>array</type><methodname>array_pad</methodname> <methodparam><type>array</type><parameter>input</parameter></methodparam> <methodparam><type>int</type><parameter>pad_size</parameter></methodparam> <methodparam><type>mixed</type><parameter>pad_value</parameter></methodparam> </methodsynopsis> <para> <function>array_pad</function> ·µ»Ø <parameter>input</parameter> µÄÒ»¸ö¿½±´£¬²¢Óà <parameter>pad_value</parameter> ½«ÆäÌî²¹µ½ <parameter>pad_size</parameter> Ö¸¶¨µÄ³¤¶È¡£Èç¹û <parameter>pad_size</parameter> ΪÕý£¬ÔòÊý×é±»Ìî²¹µ½ÓҲ࣬Èç¹ûΪ¸ºÔò´Ó×ó²à¿ªÊ¼Ìî²¹¡£Èç¹û <parameter>pad_size</parameter> µÄ¾ø¶ÔֵСÓÚ»òµÈÓÚ <parameter>input</parameter> Êý×éµÄ³¤¶ÈÔòûÓÐÈκÎÌî²¹¡£ </para> <para> <example> <title><function>array_pad</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $input = array (12, 10, 9); $result = array_pad ($input, 5, 0); // result is array (12, 10, 9, 0, 0) $result = array_pad ($input, -7, -1); // result is array (-1, -1, -1, -1, 12, 10, 9) $result = array_pad ($input, 2, "noop"); // not padded ]]> </programlisting> </example> </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 --> Index: phpdoc-zh/reference/array/functions/array-pop.xml +++ phpdoc-zh/reference/array/functions/array-pop.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-pop"> <refnamediv> <refname>array_pop</refname> <refpurpose>½«Êý×é×îºóÒ»¸öµ¥Ôªµ¯³ö£¨³öÕ»£©</refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>mixed</type><methodname>array_pop</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> </methodsynopsis> <para> <function>array_pop</function> µ¯³ö²¢·µ»Ø <parameter>array</parameter> Êý×éµÄ×îºóÒ»¸öµ¥Ôª£¬²¢½«Êý×é <parameter>array</parameter> µÄ³¤¶È¼õÒ»¡£Èç¹û <parameter>array</parameter> Ϊ¿Õ£¨»òÕß²»ÊÇÊý×飩½«·µ»Ø &null;¡£ </para> <para> <example> <title><function>array_pop</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $stack = array ("orange", "banana", "apple", "raspberry"); $fruit = array_pop ($stack); ]]> </programlisting> <para> ¾¹ý´Ë²Ù×÷ºó£¬<varname>$stack</varname> ½«Ö»ÓÐ 3 ¸öµ¥Ôª£º <screen role="php"> <![CDATA[ Array ( [0] => orange [1] => banana [2] => apple ) ]]> </screen> ²¢ÇÒ <literal>rasberry</literal> ½«±»¸³¸ø <varname>$fruit</varname>¡£ </para> </example> </para> &return.falseproblem; <para> ²Î¼û <function>array_push</function>£¬<function>array_shift</function> ºÍ <function>array_unshift</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 --> Index: phpdoc-zh/reference/array/functions/array-push.xml +++ phpdoc-zh/reference/array/functions/array-push.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-push"> <refnamediv> <refname>array_push</refname> <refpurpose> ½«Ò»¸ö»ò¶à¸öµ¥ÔªÑ¹ÈëÊý×éµÄĩ⣨ÈëÕ»£© </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>int</type><methodname>array_push</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> <methodparam><type>mixed</type><parameter>var</parameter></methodparam> <methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam> </methodsynopsis> <para> <function>array_push</function> ½« <parameter>array</parameter> µ±³ÉÒ»¸öÕ»£¬²¢½«´«ÈëµÄ±äÁ¿Ñ¹Èë <parameter>array</parameter> µÄĩβ¡£ <parameter>array</parameter> µÄ³¤¶È½«Ôö¼ÓÈëÕ»±äÁ¿µÄÊýÄ¿¡£ºÍÈçÏÂЧ¹ûÏàͬ£º <programlisting role="php"> <![CDATA[ $array[] = $var; ]]> </programlisting> ²¢¶Ôÿ¸ö <parameter>var</parameter> ÖØ¸´ÒÔÉ϶¯×÷¡£ </para> <para> ·µ»ØÊý×éеĵ¥Ôª×ÜÊý¡£ </para> <para> <example> <title><function>array_push</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $stack = array ("orange", "banana"); array_push ($stack, "apple", "raspberry"); ]]> </programlisting> <para> ±¾Àý½«Ê¹ <varname>$stack</varname> ¾ßÓÐÈçϵ¥Ôª£º <screen role="php"> <![CDATA[ Array ( [0] => orange [1] => banana [2] => apple [3] => raspberry ) ]]> </screen> </para> </example> </para> <para> ²Î¼û <function>array_pop</function>£¬<function>array_shift</function> ºÍ <function>array_unshift</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 --> Index: phpdoc-zh/reference/array/functions/array-rand.xml +++ phpdoc-zh/reference/array/functions/array-rand.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-rand"> <refnamediv> <refname>array_rand</refname> <refpurpose> ´ÓÊý×éÖÐËæ»úÈ¡³öÒ»¸ö»ò¶à¸öµ¥Ôª </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>mixed</type><methodname>array_rand</methodname> <methodparam><type>array</type><parameter>input</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>num_req</parameter></methodparam> </methodsynopsis> <para> <function>array_rand</function> ÔÚÄãÏë´ÓÊý×éÖÐÈ¡³öÒ»¸ö»ò¶à¸öËæ»úµÄµ¥ÔªÊ±Ï൱ÓÐÓá£Ëü½ÓÊÜ <parameter>input</parameter> ×÷ΪÊäÈëÊý×éºÍÒ»¸ö¿ÉÑ¡µÄ²ÎÊý <parameter>num_req</parameter>£¬Ö¸Ã÷ÁËÄãÏëÈ¡³ö¶àÉÙ¸öµ¥Ôª £ Èç¹ûûÓÐÖ¸¶¨£¬Ä¬ÈÏΪ 1¡£ </para> <para> Èç¹ûÄãֻȡ³öÒ»¸ö£¬<function>array_rand</function> ·µ»ØÒ»¸öËæ»úµ¥ÔªµÄ¼üÃû¡£·ñÔò¾Í·µ»ØÒ»¸ö°üº¬Ëæ»ú¼üÃûµÄÊý×é¡£ÕâÑùÄã¾Í¿ÉÒÔËæ»ú´ÓÊý×éÖÐÈ¡³ö¼üÃûºÍÖµ¡£ </para> <para> ²»ÒªÍü¼Çµ÷Óà <function>srand</function> À´ÈöÏÂËæ»úÊý·¢ÉúÆ÷µÄÖÖ×Ó¡£ </para> <para> <example> <title><function>array_rand</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ srand ((float) microtime() * 10000000); $input = array ("Neo", "Morpheus", "Trinity", "Cypher", "Tank"); $rand_keys = array_rand ($input, 2); print $input[$rand_keys[0]]."\n"; print $input[$rand_keys[1]]."\n"; ]]> </programlisting> </example> </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 --> Index: phpdoc-zh/reference/array/functions/array-reduce.xml +++ phpdoc-zh/reference/array/functions/array-reduce.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-reduce"> <refnamediv> <refname>array_reduce</refname> <refpurpose> Óûص÷º¯Êýµü´úµØ½«Êý×é¼ò»¯Îªµ¥Ò»µÄÖµ function </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>mixed</type><methodname>array_reduce</methodname> <methodparam><type>array</type><parameter>input</parameter></methodparam> <methodparam><type>mixed</type><parameter>callback</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>initial</parameter></methodparam> </methodsynopsis> <para> <function>array_reduce</function> ½«»Øµ÷º¯Êý <parameter>callback</parameter> µü´úµØ×÷Óõ½ <parameter>input</parameter> Êý×éÖеÄÿһ¸öµ¥ÔªÖУ¬´Ó¶ø½«Êý×é¼ò»¯Îªµ¥Ò»µÄÖµ¡£Èç¹ûÖ¸¶¨ÁË¿ÉÑ¡²ÎÊý <parameter>initial</parameter>£¬¸Ã²ÎÊý½«±»µ±³ÉÊÇÊý×éÖеĵÚÒ»¸öÖµÀ´´¦Àí£¬»òÕßÈç¹ûÊý×éΪ¿ÕµÄ»°¾Í×÷Ϊ×îÖÕ·µ»ØÖµ¡£ </para> <para> <example> <title><function>array_reduce</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ function rsum($v, $w) { $v += $w; return $v; } function rmul($v, $w) { $v *= $w; return $v; } $a = array(1, 2, 3, 4, 5); $x = array(); $b = array_reduce($a, "rsum"); $c = array_reduce($a, "rmul", 10); $d = array_reduce($x, "rsum", 1); ]]> </programlisting> </example> </para> <para> Õ⽫ʹ <varname>$b</varname> µÄֵΪ <literal>15</literal>£¬<varname>$c</varname> µÄֵΪ <literal>1200</literal>£¨= 1*2*3*4*5*10£©£¬ÒÔ¼° <varname>$d</varname> µÄֵΪ <literal>1</literal>¡£ </para> <para> ²Î¼û <function>array_filter</function> ºÍ <function>array_map</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 --> Index: phpdoc-zh/reference/array/functions/array-reverse.xml +++ phpdoc-zh/reference/array/functions/array-reverse.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-reverse"> <refnamediv> <refname>array_reverse</refname> <refpurpose> ·µ»ØÒ»¸ö½«µ¥Ôª·´ÐòµÄÊý×é </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>array</type><methodname>array_reverse</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> <methodparam choice="opt"><type>bool</type><parameter>preserve_keys</parameter></methodparam> </methodsynopsis> <para> <function>array_reverse</function> ½ÓÊÜÊý×é <parameter>array</parameter> ×÷ΪÊäÈë²¢·µ»ØÒ»¸öµ¥ÔªÎªÏ෴˳ÐòµÄÐÂÊý×飬Èç¹û <parameter>preserve_keys</parameter> Ϊ &true; Ôò±£ÁôÔÀ´µÄ¼üÃû¡£ </para> <para> <example> <title><function>array_reverse</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $input = array ("php", 4.0, array ("green", "red")); $result = array_reverse ($input); $result_keyed = array_reverse ($input, TRUE); ]]> </programlisting> <para> Õ⽫ʹ <varname>$result</varname> ºÍ <varname>$result_keyed</varname> ¾ßÓÐÏàͬµÄµ¥Ôª£¬µ«ÊÇ×¢Òâ¼üÃûµÄÇø±ð¡£<varname>$result</varname> ºÍ <varname>$result_keyed</varname> µÄ´òÓ¡Êä³öÏÔʾ·Ö±ðΪ£º <screen role="php"> <![CDATA[ Array ( [0] => Array ( [0] => green [1] => red ) [1] => 4 [2] => php ) Array ( [2] => Array ( [0] => green [1] => red ) [1] => 4 [0] => php ) ]]> </screen> </para> </example> </para> <note> <para> µÚ¶þ¸ö²ÎÊýÊÇ PHP 4.0.3 ÖÐмӵġ£ </para> </note> </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 --> Index: phpdoc-zh/reference/array/functions/array-search.xml +++ phpdoc-zh/reference/array/functions/array-search.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-search"> <refnamediv> <refname>array_search</refname> <refpurpose> ÔÚÊý×éÖÐËÑË÷¸ø¶¨µÄÖµ£¬Èç¹û³É¹¦Ôò·µ»ØÏàÓ¦µÄ¼üÃû </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>mixed</type><methodname>array_search</methodname> <methodparam><type>mixed</type><parameter>needle</parameter></methodparam> <methodparam><type>array</type><parameter>haystack</parameter></methodparam> <methodparam choice="opt"><type>bool</type><parameter>strict</parameter></methodparam> </methodsynopsis> <para> ÔÚ <parameter>haystack</parameter> ÖÐËÑË÷ <parameter>needle</parameter> ²ÎÊý²¢ÔÚÕÒµ½µÄÇé¿öÏ·µ»Ø¼üÃû£¬·ñÔò·µ»Ø &false;¡£ </para> <note> <para> ÔÚ PHP 4.2.0 ֮ǰ£¬<function>array_search</function> ÔÚʧ°Üʱ·µ»Ø <constant>NULL</constant> ¶ø²»ÊÇ &false;¡£ </para> </note> <para> Èç¹û¿ÉÑ¡µÄµÚÈý¸ö²ÎÊý <parameter>strict</parameter> Ϊ &true;£¬Ôò <function>array_search</function> »¹½«ÔÚ <parameter>haystack</parameter> Öмì²é <parameter>needle</parameter> µÄÀàÐÍ¡£ </para> &return.falseproblem; <para> ²Î¼û <function>array_keys</function> ºÍ <function>in_array</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 --> Index: phpdoc-zh/reference/array/functions/array-shift.xml +++ phpdoc-zh/reference/array/functions/array-shift.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.5 Maintainer: dallas Status: ready --> <refentry id="function.array-shift"> <refnamediv> <refname>array_shift</refname> <refpurpose> ½«Êý×鿪ͷµÄµ¥ÔªÒƳöÊý×é </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>mixed</type><methodname>array_shift</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> </methodsynopsis> <para> <function>array_shift</function> ½« <parameter>array</parameter> µÄµÚÒ»¸öµ¥ÔªÒƳö²¢×÷Ϊ½á¹û·µ»Ø£¬½« <parameter>array</parameter> µÄ³¤¶È¼õÒ»²¢½«ËùÓÐÆäËüµ¥ÔªÏòÇ°ÒÆ¶¯Ò»Î»¡£ËùÓеÄÊý×Ö¼üÃû½«¸ÄΪ´ÓÁ㿪ʼ¼ÆÊý£¬ÎÄ×Ö¼üÃû½«²»±ä¡£Èç¹û <parameter>array</parameter> Ϊ¿Õ£¨»òÕß²»ÊÇÊý×飩£¬Ôò·µ»Ø &null;¡£ </para> <para> <example> <title><function>array_shift</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $stack = array ("orange", "banana", "apple", "raspberry"); $fruit = array_shift ($stack); ]]> </programlisting> <para> Õ⽫ʹ <varname>$stack</varname> ʣϠ3 ¸öµ¥Ôª£º <screen role="php"> <![CDATA[ Array ( [0] => banana [1] => apple [2] => raspberry ) ]]> </screen> ²¢ÇÒ <literal>orange</literal> ±»¸³¸øÁË <varname>$fruit</varname>¡£ </para> </example> </para> <para> ²Î¼û <function>array_unshift</function>£¬<function>array_push</function> ºÍ <function>array_pop</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 --> Index: phpdoc-zh/reference/array/functions/array-slice.xml +++ phpdoc-zh/reference/array/functions/array-slice.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.4 Maintainer: dallas Status: ready --> <refentry id="function.array-slice"> <refnamediv> <refname>array_slice</refname> <refpurpose>´ÓÊý×éÖÐÈ¡³öÒ»¶Î</refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>array</type><methodname>array_slice</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> <methodparam><type>int</type><parameter>offset</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter> length </parameter></methodparam> </methodsynopsis> <para> <function>array_slice</function> ·µ»Ø¸ù¾Ý <parameter>offset</parameter> ºÍ <parameter>length</parameter> ²ÎÊýËùÖ¸¶¨µÄ <parameter>array</parameter> Êý×éÖеÄÒ»¶ÎÐòÁС£ </para> <para> Èç¹û <parameter>offset</parameter> ΪÕý£¬ÔòÐòÁн«´Ó <parameter>array</parameter> ÖÐµÄ´ËÆ«ÒÆÁ¿¿ªÊ¼¡£Èç¹û <parameter>offset</parameter> Ϊ¸º£¬ÔòÐòÁн«´Ó <parameter>array</parameter> ÖоàÀëÄ©¶ËÕâôԶµÄµØ·½¿ªÊ¼¡£ </para> <para> Èç¹û¸ø³öÁË <parameter>length</parameter> ²¢ÇÒΪÕý£¬ÔòÐòÁÐÖн«¾ßÓÐÕâô¶àµÄµ¥Ôª¡£Èç¹û¸ø³öÁË <parameter>length</parameter> ²¢ÇÒΪ¸º£¬ÔòÐòÁн«ÖÕÖ¹ÔÚ¾àÀëÊý×éÄ©¶ËÕâôԶµÄµØ·½¡£Èç¹ûÊ¡ÂÔ£¬ÔòÐòÁн«´Ó <parameter>offset</parameter> ¿ªÊ¼Ò»Ö±µ½ <parameter>array</parameter> µÄÄ©¶Ë¡£ </para> <para> ×¢Òâ <function>array_slice</function> ½«ºöÂÔ¼üÃû£¬²¢ÇÒÊǸù¾Ýµ¥ÔªÔÚÊý×éÖеÄʵ¼ÊλÖÃÀ´¼ÆËãÆ«ÒÆÁ¿ºÍ³¤¶ÈµÄ¡£ </para> <para> <example> <title><function>array_slice</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ $input = array ("a", "b", "c", "d", "e"); $output = array_slice ($input, 2); // returns "c", "d", and "e" $output = array_slice ($input, 2, -1); // returns "c", "d" $output = array_slice ($input, -2, 1); // returns "d" $output = array_slice ($input, 0, 3); // returns "a", "b", and "c" ]]> </programlisting> </example> </para> <para> ²Î¼û <function>array_splice</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 -->