cvs: /phpdoc/functions array.sgml

From: Date: Sat, 17 Jul 1999 11:41:41 +0000
Subject: cvs: /phpdoc/functions array.sgml
Groups: php.dev 
Request: Send a blank email to php-dev+get-8644@lists.php.net to get a copy of this message
andrey Sat Jul 17 11:41:41 1999 EDT Modified files: /phpdoc/functions array.sgml Log: Documented compact() function. Index: phpdoc/functions/array.sgml diff -u phpdoc/functions/array.sgml:1.15 phpdoc/functions/array.sgml:1.16 --- phpdoc/functions/array.sgml:1.15 Fri Jul 16 18:49:11 1999 +++ phpdoc/functions/array.sgml Sat Jul 17 11:41:41 1999 @@ -628,6 +628,62 @@ </refsect1> </refentry> + <refentry id="function.compact"> + <refnamediv> + <refname>compact</refname> + <refpurpose>Create array containing variables and their values</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcdef>array <function>compact</function></funcdef> + <paramdef><parameter>string varname | array + varnames</parameter></paramdef> + <paramdef><parameter><optional>...</optional></parameter></paramdef> + </funcsynopsis> + + <para> + <function>compact</function> takes a variable number of + parameters. Each parameter can be either a string containing the + name of the variable, or an array of variable names. The array + can contain other arrays of variable names inside it; + <function>compact</function> handles it recursively. + + <para> + For each of these, <function>compact</function> looks for a + variable with that name in the current symbol table and adds it + to the output array such that the variable name becomes the key + and the contents of the variable become the value for that key. + In short, it does the opposite of <function>extract</function>. + It returns the output array with all the variables added to it. + + <para> + <example> + <title><function>compact</function> example</title> + <programlisting> +$city = "San Francisco"; +$state = "CA"; +$event = "SIGGRAPH"; + +$location_vars = array("city", "state"); + +$result = compact("event", $location_vars); + </programlisting> + + <para> + After this, $result will be array("event" => "SIGGRAPH", "city" => "San Francisco", "state" => "CA"). + </example> + + <para> + See also <function>extract</function>. + + <note> + <para> + This function was added in PHP 4.0. + </note> + </refsect1> + </refentry> + <refentry id="function.count"> <refnamediv> <refname>count</refname>

« previous php.dev (#8644) next »