mirror of
https://github.com/php/doc-ja.git
synced 2026-03-25 15:42:08 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@228555 c90b9560-bf6c-de11-be94-00142212c4b1
106 lines
3.0 KiB
XML
106 lines
3.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 1.8 $ -->
|
|
<!-- EN-Revision: 1.14 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka -->
|
|
<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 role="reference">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> の長さは渡された変数の数だけ増加します。
|
|
各 <parameter>var</parameter>
|
|
毎に以下を繰り返すことと同じ効果があります。
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$array[] = $var;
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
各 <parameter>var</parameter> で繰り返されます。
|
|
</para>
|
|
<para>
|
|
処理後の配列の中の要素の数を返します。
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>array_push</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$stack = array("orange", "banana");
|
|
array_push($stack, "apple", "raspberry");
|
|
print_r($stack);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[0] => orange
|
|
[1] => banana
|
|
[2] => apple
|
|
[3] => raspberry
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
もし配列にひとつの要素を加えるために
|
|
<function>array_push</function> を使用するなら、
|
|
関数を呼ぶオーバーヘッドがないので、<literal>$array[] = </literal>
|
|
を使用するほうがいいです。
|
|
</simpara>
|
|
</note>
|
|
<note>
|
|
<simpara>
|
|
最初の引数が配列でない場合、<function>array_push</function>
|
|
は警告を発生させます。これは新規配列を生成する場合における
|
|
<literal>$var[]</literal> の動作と異なります。
|
|
</simpara>
|
|
</note>
|
|
<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
|
|
-->
|