svn: /phpdoc/zh/trunk/reference/array/functions/ array-merge-recursive.xml array-replace-recursive.xml array-replace.xml array-reverse.xml array-unshift.xml compact.xml count.xml list.xml

[email protected] (Dai Jie)
Newsgroups php.doc.zh
Message-ID <[email protected]>
daijie                                   Sun, 18 Nov 2018 12:06:46 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=346013

Log:
Sync with EN.

Changed paths:
    U   phpdoc/zh/trunk/reference/array/functions/array-merge-recursive.xml
    U   phpdoc/zh/trunk/reference/array/functions/array-replace-recursive.xml
    U   phpdoc/zh/trunk/reference/array/functions/array-replace.xml
    U   phpdoc/zh/trunk/reference/array/functions/array-reverse.xml
    U   phpdoc/zh/trunk/reference/array/functions/array-unshift.xml
    U   phpdoc/zh/trunk/reference/array/functions/compact.xml
    U   phpdoc/zh/trunk/reference/array/functions/count.xml
    U   phpdoc/zh/trunk/reference/array/functions/list.xml
svn-diffs-346013.txt (text/x-diff, 14.5 KB)
Modified: phpdoc/zh/trunk/reference/array/functions/array-merge-recursive.xml
===================================================================
--- phpdoc/zh/trunk/reference/array/functions/array-merge-recursive.xml	2018-11-18 11:15:45 UTC (rev 346012)
+++ phpdoc/zh/trunk/reference/array/functions/array-merge-recursive.xml	2018-11-18 12:06:46 UTC (rev 346013)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 330179 Maintainer: daijie Status: ready -->
-  <refentry xml:id="function.array-merge-recursive" xmlns="http://docbook.org/ns/docbook">
+<!-- EN-Revision: 345370 Maintainer: daijie Status: ready -->
+<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.array-merge-recursive">
    <refnamediv>
     <refname>array_merge_recursive</refname>
     <refpurpose>递归地合并一个或多个数组</refpurpose>
@@ -18,7 +18,7 @@
      <function>array_merge_recursive</function> 将一个或多个数组的单元合并起来,一个数组中的值附加在前一个数组的后面。返回作为结果的数组。
     </para>
     <para>
-     如果输入的数组中有相同的字符串键名,则这些值会被合并到一个数组中去,这将递归下去,因此如果一个值本身是一个数组,本函数将按照相应的条目把它合并为另一个数组。然而,如果数组具有相同的数组键名,后一个值将不会覆盖原来的值,而是附加到后面。
+     如果输入的数组中有相同的字符串键名,则这些值会被合并到一个数组中去,这将递归下去,因此如果一个值本身是一个数组,本函数将按照相应的条目把它合并为另一个数组。需要注意的是,如果数组具有相同的数值键名,后一个值将不会覆盖原来的值,而是附加到后面。
     </para>
    </refsect1>


Modified: phpdoc/zh/trunk/reference/array/functions/array-replace-recursive.xml
===================================================================
--- phpdoc/zh/trunk/reference/array/functions/array-replace-recursive.xml	2018-11-18 11:15:45 UTC (rev 346012)
+++ phpdoc/zh/trunk/reference/array/functions/array-replace-recursive.xml	2018-11-18 12:06:46 UTC (rev 346013)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 331477 Maintainer: daijie Status: ready -->
+<!-- EN-Revision: 345370 Maintainer: daijie Status: ready -->
 <refentry xml:id="function.array-replace-recursive" xmlns="http://docbook.org/ns/docbook">
  <refnamediv>
   <refname>array_replace_recursive</refname>
@@ -11,7 +11,6 @@
   <methodsynopsis>
    <type>array</type><methodname>array_replace_recursive</methodname>
    <methodparam><type>array</type><parameter>array1</parameter></methodparam>
-   <methodparam><type>array</type><parameter>array2</parameter></methodparam>
    <methodparam choice="opt"><type>array</type><parameter>...</parameter></methodparam>
   </methodsynopsis>
   <para>
@@ -24,7 +23,7 @@
   <para> <function>array_replace_recursive</function> 是递归的:它将遍历数组并将相同的处理应用到数组的内部值。
   </para>
   <para>
-   如果数组 <parameter>array1</parameter> 中的值是标量,它的值将被第二个数组 <parameter>array2</parameter> 中的值替换,它可能是一个标量或者数组。如果 <parameter>array1</parameter> 和 <parameter>array2</parameter> 中的值都是数组,<function>array_replace_recursive</function> 函数将递归地替换它们各自的值。
+   如果第一个数组中的值是标量,它的值将被第二个数组中的值替换,它可能是一个标量或者数组。如果第一个数组和第二个数组中的值都是数组,<function>array_replace_recursive</function> 函数将递归地替换它们各自的值。
   </para>
  </refsect1>
  <refsect1 role="parameters">
@@ -40,18 +39,10 @@
      </listitem>
     </varlistentry>
     <varlistentry>
-     <term><parameter>array2</parameter></term>
-     <listitem>
-      <para>
-       从此数组中提取替换值。
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
      <term><parameter>...</parameter></term>
      <listitem>
       <para>
-       可选项。更多包含要提取元素的数组。
+       可选项。包含要提取元素的数组。
       </para>
      </listitem>
     </varlistentry>

Modified: phpdoc/zh/trunk/reference/array/functions/array-replace.xml
===================================================================
--- phpdoc/zh/trunk/reference/array/functions/array-replace.xml	2018-11-18 11:15:45 UTC (rev 346012)
+++ phpdoc/zh/trunk/reference/array/functions/array-replace.xml	2018-11-18 12:06:46 UTC (rev 346013)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 332158 Maintainer: daijie Status: ready -->
+<!-- EN-Revision: 345370 Maintainer: daijie Status: ready -->
 <refentry xml:id="function.array-replace" xmlns="http://docbook.org/ns/docbook">
  <refnamediv>
   <refname>array_replace</refname>
@@ -11,7 +11,6 @@
   <methodsynopsis>
    <type>array</type><methodname>array_replace</methodname>
    <methodparam><type>array</type><parameter>array1</parameter></methodparam>
-   <methodparam><type>array</type><parameter>array2</parameter></methodparam>
    <methodparam choice="opt"><type>array</type><parameter>...</parameter></methodparam>
   </methodsynopsis>
   <para>
@@ -34,18 +33,10 @@
      </listitem>
     </varlistentry>
     <varlistentry>
-     <term><parameter>array2</parameter></term>
-     <listitem>
-      <para>
-       从此数组中提取替换值。
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
      <term><parameter>...</parameter></term>
      <listitem>
       <para>
-       包含要提取元素的更多数组。
+       包含要提取元素的数组。
        后面的数组里的值会覆盖前面的值。
       </para>
      </listitem>

Modified: phpdoc/zh/trunk/reference/array/functions/array-reverse.xml
===================================================================
--- phpdoc/zh/trunk/reference/array/functions/array-reverse.xml	2018-11-18 11:15:45 UTC (rev 346012)
+++ phpdoc/zh/trunk/reference/array/functions/array-reverse.xml	2018-11-18 12:06:46 UTC (rev 346013)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 334592 Maintainer: daijie Status: ready -->
+<!-- EN-Revision: 343899 Maintainer: daijie Status: ready -->
   <refentry xml:id="function.array-reverse" xmlns="http://docbook.org/ns/docbook">
    <refnamediv>
     <refname>array_reverse</refname>
@@ -13,7 +13,7 @@
   <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><initializer>false</initializer></methodparam>
+   <methodparam choice="opt"><type>bool</type><parameter>preserve_keys</parameter><initializer>&false;</initializer></methodparam>
   </methodsynopsis>
     <para>
      <function>array_reverse</function> 接受数组

Modified: phpdoc/zh/trunk/reference/array/functions/array-unshift.xml
===================================================================
--- phpdoc/zh/trunk/reference/array/functions/array-unshift.xml	2018-11-18 11:15:45 UTC (rev 346012)
+++ phpdoc/zh/trunk/reference/array/functions/array-unshift.xml	2018-11-18 12:06:46 UTC (rev 346013)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 340325 Maintainer: daijie Status: ready -->
+<!-- EN-Revision: 344569 Maintainer: daijie Status: ready -->
   <refentry xml:id="function.array-unshift" xmlns="http://docbook.org/ns/docbook">
    <refnamediv>
     <refname>array_unshift</refname>
@@ -13,7 +13,6 @@
   <methodsynopsis>
    <type>int</type><methodname>array_unshift</methodname>
    <methodparam><type>array</type><parameter role="reference">array</parameter></methodparam>
-   <methodparam><type>mixed</type><parameter>value1</parameter></methodparam>
    <methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
   </methodsynopsis>
     <para>
@@ -34,10 +33,10 @@
      </listitem>
     </varlistentry>
     <varlistentry>
-     <term><parameter>value1</parameter></term>
+     <term><parameter>...</parameter></term>
      <listitem>
       <para>
-       开头插入的变量。
+       插入的变量。
       </para>
      </listitem>
     </varlistentry>
@@ -50,6 +49,31 @@
     返回 <parameter>array</parameter> 数组新的单元数目。
   </para>
  </refsect1>
+
+ <refsect1 role="changelog">
+  &reftitle.changelog;
+  <para>
+   <informaltable>
+    <tgroup cols="2">
+     <thead>
+      <row>
+       <entry>&Version;</entry>
+       <entry>&Description;</entry>
+      </row>
+     </thead>
+     <tbody>
+      <row>
+       <entry>7.3.0</entry>
+       <entry>
+        现在可以只用一个参数来调用,之前至少需要两个参数。
+       </entry>
+      </row>
+     </tbody>
+    </tgroup>
+   </informaltable>
+  </para>
+ </refsect1>
+
  <refsect1 role="examples">
   &reftitle.examples;
   <para>

Modified: phpdoc/zh/trunk/reference/array/functions/compact.xml
===================================================================
--- phpdoc/zh/trunk/reference/array/functions/compact.xml	2018-11-18 11:15:45 UTC (rev 346012)
+++ phpdoc/zh/trunk/reference/array/functions/compact.xml	2018-11-18 12:06:46 UTC (rev 346013)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 331477 Maintainer: daijie Status: ready -->
+<!-- EN-Revision: 345170 Maintainer: daijie Status: ready -->
 <refentry xml:id="function.compact" xmlns="http://docbook.org/ns/docbook">
  <refnamediv>
   <refname>compact</refname>
@@ -23,9 +23,11 @@
      在当前的符号表中查找该变量名并将它添加到输出的数组中,变量名成为键名而变量的内容成为该键的值。简单说,它做的事和
      <function>extract</function> 正好相反。返回将所有变量添加进去后的数组。
     </para>
-    <para>
-     任何没有变量名与之对应的字符串都被略过。
-    </para>
+  <note>
+   <para>
+    在 PHP 7.3 之前版本,未设置的字符串会被静默忽略。
+   </para>
+  </note>
  </refsect1>
  <refsect1 role="parameters">
   &reftitle.parameters;
@@ -49,6 +51,37 @@
    返回输出的数组,包含了添加的所有变量。
   </para>
  </refsect1>
+
+ <refsect1 role="errors">
+  &reftitle.errors;
+  <para>
+   如果字符串指向的变量未定义,<function>compact</function> 会产生 E_NOTICE 级错误。
+  </para>
+ </refsect1>
+
+ <refsect1 role="changelog"><!-- {{{ -->
+  &reftitle.changelog;
+  <informaltable>
+   <tgroup cols="2">
+    <thead>
+     <row>
+      <entry>&Version;</entry>
+      <entry>&Description;</entry>
+     </row>
+    </thead>
+    <tbody>
+     <row>
+      <entry>7.3.0</entry>
+      <entry>
+        现在,如果字符串指向的变量未定义,<function>compact</function> 会产生 E_NOTICE 级错误。
+       在此之前,此类问题会静默忽略掉。
+      </entry>
+     </row>
+    </tbody>
+   </tgroup>
+  </informaltable>
+ </refsect1><!-- }}} -->
+
  <refsect1 role="examples">
   &reftitle.examples;
   <para>

Modified: phpdoc/zh/trunk/reference/array/functions/count.xml
===================================================================
--- phpdoc/zh/trunk/reference/array/functions/count.xml	2018-11-18 11:15:45 UTC (rev 346012)
+++ phpdoc/zh/trunk/reference/array/functions/count.xml	2018-11-18 12:06:46 UTC (rev 346013)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 343711 Maintainer: daijie Status: ready -->
+<!-- EN-Revision: 345126 Maintainer: daijie Status: ready -->
   <refentry xml:id="function.count" xmlns="http://docbook.org/ns/docbook">
    <refnamediv>
     <refname>count</refname>
@@ -69,12 +69,6 @@
    有个例外:如果
      <parameter>array_or_countable</parameter> 是 &null; 则结果是 <literal>0</literal>。
   </para>
-  <caution>
-   <para>
-     <function>count</function> 对没有初始化的变量返回 0,但对于空的数组也会返回 0。
-    用 <function>isset</function> 来测试变量是否已经初始化。
-   </para>
-  </caution>
  </refsect1>
  <refsect1 role="examples">
   &reftitle.examples;

Modified: phpdoc/zh/trunk/reference/array/functions/list.xml
===================================================================
--- phpdoc/zh/trunk/reference/array/functions/list.xml	2018-11-18 11:15:45 UTC (rev 346012)
+++ phpdoc/zh/trunk/reference/array/functions/list.xml	2018-11-18 12:06:46 UTC (rev 346013)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 340033 Maintainer: daijie Status: ready -->
+<!-- EN-Revision: 345209 Maintainer: daijie Status: ready -->
   <refentry xml:id="function.list" xmlns="http://docbook.org/ns/docbook">
    <refnamediv>
     <refname>list</refname>
@@ -20,7 +20,7 @@
     </para>
   <note>
    <para>
-    <function>list</function> 仅能用于数字索引的数组,并假定数字索引从 0 开始。
+    在 PHP 7.1.0 之前的版本,<function>list</function> 仅能用于数字索引的数组,并假定数字索引从 0 开始。
    </para>
   </note>
   <warning>
@@ -78,6 +78,13 @@
      </thead>
      <tbody>
       <row>
+       <entry>7.1.0</entry>
+       <entry>
+        现在可以指定 <function>list</function> 中的键。
+        这就可以解构非数字键或者无顺序的数组。
+       </entry>
+      </row>
+      <row>
        <entry>7.0.0</entry>
        <entry>
         <link linkend="migration70.incompatible.variable-handling.list.order">
@@ -273,6 +280,39 @@
     </screen>
    </example>
   </para>
+  <para>
+   <example>
+    <title>带键的 <function>list</function></title>
+    <simpara>
+     从 PHP 7.1.0 开始,<function>list</function> 可以包含显式的键,可赋值到任意表达式。
+     可以混合使用数字和字符串键。但是不能混合有键和无键不能混用。
+    </simpara>
+    <programlisting role="php">
+<![CDATA[
+<?php
+$data = [
+    ["id" => 1, "name" => 'Tom'],
+    ["id" => 2, "name" => 'Fred'],
+];
+foreach ($data as ["id" => $id, "name" => $name]) {
+    echo "id: $id, name: $name\n";
+}
+echo PHP_EOL;
+list(1 => $second, 3 => $fourth) = [1, 2, 3, 4];
+echo "$second, $fourth\n";
+]]>
+    </programlisting>
+    &example.outputs;
+    <screen>
+<![CDATA[
+id: 1, name: Tom
+id: 2, name: Fred
+
+2, 4
+]]>
+    </screen>
+   </example>
+  </para>
  </refsect1>
  <refsect1 role="seealso">
   &reftitle.seealso;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.