1
0
mirror of https://github.com/php/doc-zh.git synced 2026-03-26 16:12:19 +01:00
Files
archived-doc-zh/reference/array/functions/array-sum.xml
Dallas Wang 630ac05213 Translation completed.
git-svn-id: https://svn.php.net/repository/phpdoc/zh/trunk@95449 c90b9560-bf6c-de11-be94-00142212c4b1
2002-09-11 05:04:54 +00:00

72 lines
1.7 KiB
XML
Executable File

<?xml version="1.0" encoding="gb2312"?>
<!-- $Revision: 1.1 $ -->
<!-- $Author: dallas $ -->
<!-- EN-Revision: 1.4 Maintainer: dallas Status: ready -->
<refentry id="function.array-sum">
<refnamediv>
<refname>array_sum</refname>
<refpurpose>
计算数组中所有值的和
</refpurpose>
</refnamediv>
<refsect1>
<title>说明</title>
<methodsynopsis>
<type>mixed</type><methodname>array_sum</methodname>
<methodparam><type>array</type><parameter>array</parameter></methodparam>
</methodsynopsis>
<para>
<function>array_sum</function> 将数组中的所有值的和以整数或浮点数的结果返回。
</para>
<para>
<example>
<title><function>array_sum</function> 例子</title>
<programlisting role="php">
<![CDATA[
$a = array(2, 4, 6, 8);
echo "sum(a) = ".array_sum($a)."\n";
$b = array("a"=>1.2,"b"=>2.3,"c"=>3.4);
echo "sum(b) = ".array_sum($b)."\n";
]]>
</programlisting>
<para>
以上程序输出为:
<screen role="php">
<![CDATA[
sum(a) = 20
sum(b) = 6.9
]]>
</screen>
</para>
</example>
</para>
<note>
<para>
PHP 4.0.6 之前的版本修改了传入的数组本身,将其中的字符串值转换成数值(大多数情况下都转换成了零,根据具体值而定)。
</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
-->