Skip to content

Commit 630ac05

Browse files
author
Dallas Wang
committed
Translation completed.
git-svn-id: https://svn.php.net/repository/phpdoc/zh/trunk@95449 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent ec5da1f commit 630ac05

File tree

5 files changed

+476
-0
lines changed

5 files changed

+476
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="gb2312"?>
2+
<!-- $Revision: 1.1 $ -->
3+
<!-- $Author: dallas $ -->
4+
<!-- EN-Revision: 1.4 Maintainer: dallas Status: ready -->
5+
<refentry id="function.array-sum">
6+
<refnamediv>
7+
<refname>array_sum</refname>
8+
<refpurpose>
9+
计算数组中所有值的和
10+
</refpurpose>
11+
</refnamediv>
12+
<refsect1>
13+
<title>说明</title>
14+
<methodsynopsis>
15+
<type>mixed</type><methodname>array_sum</methodname>
16+
<methodparam><type>array</type><parameter>array</parameter></methodparam>
17+
</methodsynopsis>
18+
<para>
19+
<function>array_sum</function> 将数组中的所有值的和以整数或浮点数的结果返回。
20+
</para>
21+
<para>
22+
<example>
23+
<title><function>array_sum</function> 例子</title>
24+
<programlisting role="php">
25+
<![CDATA[
26+
$a = array(2, 4, 6, 8);
27+
echo "sum(a) = ".array_sum($a)."\n";
28+
29+
$b = array("a"=>1.2,"b"=>2.3,"c"=>3.4);
30+
echo "sum(b) = ".array_sum($b)."\n";
31+
]]>
32+
</programlisting>
33+
<para>
34+
以上程序输出为:
35+
<screen role="php">
36+
<![CDATA[
37+
sum(a) = 20
38+
sum(b) = 6.9
39+
]]>
40+
</screen>
41+
</para>
42+
</example>
43+
</para>
44+
<note>
45+
<para>
46+
PHP 4.0.6 之前的版本修改了传入的数组本身,将其中的字符串值转换成数值(大多数情况下都转换成了零,根据具体值而定)。
47+
</para>
48+
</note>
49+
</refsect1>
50+
</refentry>
51+
52+
<!-- Keep this comment at the end of the file
53+
Local variables:
54+
mode: sgml
55+
sgml-omittag:t
56+
sgml-shorttag:t
57+
sgml-minimize-attributes:nil
58+
sgml-always-quote-attributes:t
59+
sgml-indent-step:1
60+
sgml-indent-data:t
61+
indent-tabs-mode:nil
62+
sgml-parent-document:nil
63+
sgml-default-dtd-file:"../../../../manual.ced"
64+
sgml-exposed-tags:nil
65+
sgml-local-catalogs:nil
66+
sgml-local-ecat-files:nil
67+
End:
68+
vim600: syn=xml fen fdm=syntax fdl=2 si
69+
vim: et tw=78 syn=sgml
70+
vi: ts=1 sw=1
71+
-->
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="gb2312"?>
2+
<!-- $Revision: 1.1 $ -->
3+
<!-- $Author: dallas $ -->
4+
<!-- EN-Revision: 1.4 Maintainer: dallas Status: ready -->
5+
<refentry id="function.array-unique">
6+
<refnamediv>
7+
<refname>array_unique</refname>
8+
<refpurpose>移除数组中重复的值</refpurpose>
9+
</refnamediv>
10+
<refsect1>
11+
<title>说明</title>
12+
<methodsynopsis>
13+
<type>array</type><methodname>array_unique</methodname>
14+
<methodparam><type>array</type><parameter>array</parameter></methodparam>
15+
</methodsynopsis>
16+
<para>
17+
<function>array_unique</function> 接受
18+
<parameter>array</parameter> 作为输入并返回没有重复值的新数组。
19+
</para>
20+
<para>
21+
注意键名保留不变。<function>array_unique</function>
22+
先将值作为字符串排序,然后对每个值只保留第一个遇到的键名,接着忽略所有后面的键名。这并不意味着在未排序的
23+
<parameter>array</parameter> 中同一个值的第一个出现的键名会被保留。
24+
</para>
25+
<note>
26+
<simpara>
27+
当且仅当
28+
<literal>(string) $elem1 === (string) $elem2</literal> 时两个单元被认为相同。就是说,当字符串的表达一样时。
29+
<!-- TODO: example of it... -->
30+
</simpara>
31+
<simpara>
32+
第一个单元将被保留。
33+
</simpara>
34+
</note>
35+
<warning>
36+
<simpara>
37+
本函数在 PHP 4.0.4 中是坏的!
38+
<!-- TODO: when exactly was this broken?... -->
39+
</simpara>
40+
</warning>
41+
<para>
42+
<example>
43+
<title><function>array_unique</function> 例子</title>
44+
<programlisting role="php">
45+
<![CDATA[
46+
$input = array ("a" => "green", "red", "b" => "green", "blue", "red");
47+
$result = array_unique ($input);
48+
print_r($result);
49+
]]>
50+
</programlisting>
51+
<para>
52+
上例将输出:
53+
<screen role="php">
54+
<![CDATA[
55+
Array
56+
(
57+
[b] => green
58+
[1] => blue
59+
[2] => red
60+
)
61+
]]>
62+
</screen>
63+
</para>
64+
</example>
65+
</para>
66+
<para>
67+
<example>
68+
<title><function>array_unique</function> 和类型</title>
69+
<programlisting role="php">
70+
<![CDATA[
71+
$input = array (4,"4","3",4,3,"3");
72+
$result = array_unique ($input);
73+
var_dump($result);
74+
]]>
75+
</programlisting>
76+
<para>
77+
以上程序输出结果为(PHP 4.0.6):
78+
<screen role="php">
79+
<![CDATA[
80+
array(2) {
81+
[0]=>
82+
int(4)
83+
[2]=>
84+
string(1) "3"
85+
}
86+
]]>
87+
</screen>
88+
</para>
89+
</example>
90+
</para>
91+
</refsect1>
92+
</refentry>
93+
94+
<!-- Keep this comment at the end of the file
95+
Local variables:
96+
mode: sgml
97+
sgml-omittag:t
98+
sgml-shorttag:t
99+
sgml-minimize-attributes:nil
100+
sgml-always-quote-attributes:t
101+
sgml-indent-step:1
102+
sgml-indent-data:t
103+
indent-tabs-mode:nil
104+
sgml-parent-document:nil
105+
sgml-default-dtd-file:"../../../../manual.ced"
106+
sgml-exposed-tags:nil
107+
sgml-local-catalogs:nil
108+
sgml-local-ecat-files:nil
109+
End:
110+
vim600: syn=xml fen fdm=syntax fdl=2 si
111+
vim: et tw=78 syn=sgml
112+
vi: ts=1 sw=1
113+
-->
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="gb2312"?>
2+
<!-- $Revision: 1.1 $ -->
3+
<!-- $Author: dallas $ -->
4+
<!-- EN-Revision: 1.5 Maintainer: dallas Status: ready -->
5+
<refentry id="function.array-unshift">
6+
<refnamediv>
7+
<refname>array_unshift</refname>
8+
<refpurpose>
9+
在数组开头插入一个或多个单元
10+
</refpurpose>
11+
</refnamediv>
12+
<refsect1>
13+
<title>说明</title>
14+
<methodsynopsis>
15+
<type>int</type><methodname>array_unshift</methodname>
16+
<methodparam><type>array</type><parameter>array</parameter></methodparam>
17+
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
18+
<methodparam choice="opt"><type>mixed</type><parameter>
19+
...
20+
</parameter></methodparam>
21+
</methodsynopsis>
22+
<para>
23+
<function>array_unshift</function> 将传入的单元插入到
24+
<parameter>array</parameter> 数组的开头。注意单元是作为整体被插入的,因此传入单元将保持同样的顺序。所有的数值键名将修改为从零开始重新计数,所有的文字键名保持不变。
25+
</para>
26+
<para>
27+
返回 <parameter>array</parameter> 数组新的单元数目。
28+
</para>
29+
<para>
30+
<example>
31+
<title><function>array_unshift</function> 例子</title>
32+
<programlisting role="php">
33+
<![CDATA[
34+
$queue = array ("orange", "banana");
35+
array_unshift ($queue, "apple", "raspberry");
36+
]]>
37+
</programlisting>
38+
<para>
39+
这将使 <varname>$queue</varname> 包含如下单元:
40+
<screen role="php">
41+
<![CDATA[
42+
Array
43+
(
44+
[0] => apple
45+
[1] => raspberry
46+
[2] => orange
47+
[3] => banana
48+
)
49+
]]>
50+
</screen>
51+
</para>
52+
</example>
53+
</para>
54+
<para>
55+
参见 <function>array_shift</function>,<function>array_push</function> 和 <function>array_pop</function>。
56+
</para>
57+
</refsect1>
58+
</refentry>
59+
60+
<!-- Keep this comment at the end of the file
61+
Local variables:
62+
mode: sgml
63+
sgml-omittag:t
64+
sgml-shorttag:t
65+
sgml-minimize-attributes:nil
66+
sgml-always-quote-attributes:t
67+
sgml-indent-step:1
68+
sgml-indent-data:t
69+
indent-tabs-mode:nil
70+
sgml-parent-document:nil
71+
sgml-default-dtd-file:"../../../../manual.ced"
72+
sgml-exposed-tags:nil
73+
sgml-local-catalogs:nil
74+
sgml-local-ecat-files:nil
75+
End:
76+
vim600: syn=xml fen fdm=syntax fdl=2 si
77+
vim: et tw=78 syn=sgml
78+
vi: ts=1 sw=1
79+
-->
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="gb2312"?>
2+
<!-- $Revision: 1.1 $ -->
3+
<!-- $Author: dallas $ -->
4+
<!-- EN-Revision: 1.4 Maintainer: dallas Status: ready -->
5+
<refentry id="function.array-values">
6+
<refnamediv>
7+
<refname>array_values</refname>
8+
<refpurpose>返回数组中所有的值</refpurpose>
9+
</refnamediv>
10+
<refsect1>
11+
<title>说明</title>
12+
<methodsynopsis>
13+
<type>array</type><methodname>array_values</methodname>
14+
<methodparam><type>array</type><parameter>input</parameter></methodparam>
15+
</methodsynopsis>
16+
<para>
17+
<function>array_values</function> 返回
18+
<parameter>input</parameter> 数组中所有的值。
19+
</para>
20+
<para>
21+
<example>
22+
<title><function>array_values</function> 例子</title>
23+
<programlisting role="php">
24+
<![CDATA[
25+
$array = array ("size" => "XL", "color" => "gold");
26+
print_r(array_values ($array));
27+
]]>
28+
</programlisting>
29+
<para>
30+
上例将输出:
31+
<screen role="php">
32+
<![CDATA[
33+
Array
34+
(
35+
[0] => XL
36+
[1] => gold
37+
)
38+
]]>
39+
</screen>
40+
</para>
41+
</example>
42+
</para>
43+
<note>
44+
<para>
45+
本函数是 PHP 4 新加的,以下是 PHP 3 的实现:
46+
<example>
47+
<title>
48+
<function>array_values</function> 对PHP 3 用户的实现
49+
</title>
50+
<programlisting role="php">
51+
<![CDATA[
52+
function array_values ($arr) {
53+
$t = array();
54+
while (list($k, $v) = each ($arr)) {
55+
$t[] = $v;
56+
}
57+
return $t;
58+
}
59+
]]>
60+
</programlisting>
61+
</example>
62+
</para>
63+
</note>
64+
<para>
65+
参见 <function>array_keys</function>。
66+
</para>
67+
</refsect1>
68+
</refentry>
69+
70+
<!-- Keep this comment at the end of the file
71+
Local variables:
72+
mode: sgml
73+
sgml-omittag:t
74+
sgml-shorttag:t
75+
sgml-minimize-attributes:nil
76+
sgml-always-quote-attributes:t
77+
sgml-indent-step:1
78+
sgml-indent-data:t
79+
indent-tabs-mode:nil
80+
sgml-parent-document:nil
81+
sgml-default-dtd-file:"../../../../manual.ced"
82+
sgml-exposed-tags:nil
83+
sgml-local-catalogs:nil
84+
sgml-local-ecat-files:nil
85+
End:
86+
vim600: syn=xml fen fdm=syntax fdl=2 si
87+
vim: et tw=78 syn=sgml
88+
vi: ts=1 sw=1
89+
-->

0 commit comments

Comments
 (0)