1
0
mirror of https://github.com/php/doc-ja.git synced 2026-03-26 16:12:17 +01:00
Files
archived-doc-ja/reference/array/functions/compact.xml
Yu Watanabe 2a50fe2e6b sync to en tree.(tag, etc)
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@134980 c90b9560-bf6c-de11-be94-00142212c4b1
2003-07-13 13:45:01 +00:00

91 lines
2.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.3 $ -->
<!-- sync: 1.2 -->
<refentry id="function.compact">
<refnamediv>
<refname>compact</refname>
<refpurpose>
変数名とその値から配列を作成する
</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>array</type><methodname>compact</methodname>
<methodparam><type>mixed</type><parameter>varname</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
</methodsynopsis>
<para>
<function>compact</function>がとるパラメータの数は可変です。
各パラメータは、変数名を値とする文字列か、変数名の配列のどちらかとする
ことができます。配列は、変数名を値とする別の配列を持つことができます。
<function>compact</function>はこれを再帰的に処理します。
</para>
<para>
各引数について、<function>compact</function>は現在のシンボルテーブル
においてその名前を有する変数を探し、変数名がキー、変数の値がそのキー
に関する値となるように追加します。
端的に言うと、<function>extract</function>の逆の動作をします。
追加された全ての変数を値とする出力配列を返します。
</para>
<para>
設定されていない全ての文字列は、単にスキップされます。
</para>
<para>
<example>
<title><function>compact</function>の例</title>
<programlisting role="php">
<![CDATA[
<?php
$city = "San Francisco";
$state = "CA";
$event = "SIGGRAPH";
$location_vars = array ("city", "state");
$result = compact ("event", "nothing_here", $location_vars);
?>
]]>
</programlisting>
<para>
この例により、<varname>$result</varname>は以下のようになります:
</para>
<screen role="php">
<![CDATA[
Array
(
[event] => SIGGRAPH
[city] => San Francisco
[state] => CA
)
]]>
</screen>
</example>
</para>
<para>
<function>extract</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
-->