Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 208

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>compact</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Array Functions"
HREF="ref.array.html"><LINK
REL="PREVIOUS"
TITLE="asort"
HREF="function.asort.html"><LINK
REL="NEXT"
TITLE="count"
HREF="function.count.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.asort.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.count.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.compact"
></A
>compact</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN8481"
></A
><P
>    (PHP 4 )</P
>compact&nbsp;--&nbsp;
     Create array containing variables and their values
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN8484"
></A
><H2
>Description</H2
>array <B
CLASS="methodname"
>compact</B
> ( mixed varname [, mixed ...])<BR
></BR
><P
>&#13;     <B
CLASS="function"
>compact()</B
> 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;
     <B
CLASS="function"
>compact()</B
> handles it recursively.
    </P
><P
>&#13;     For each of these, <B
CLASS="function"
>compact()</B
> 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 <A
HREF="function.extract.html"
><B
CLASS="function"
>extract()</B
></A
>.
     It returns the output array with all the variables added to it.
    </P
><P
>&#13;     Any strings that are not set will simply be skipped.
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN8503"
></A
><P
><B
>Example 1. <B
CLASS="function"
>compact()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>$city = "San Francisco";
$state = "CA";
$event = "SIGGRAPH";

$location_vars = array ("city", "state");

$result = compact ("event", "nothing_here", $location_vars);</PRE
></TD
></TR
></TABLE
><P
>&#13;       After this, <TT
CLASS="varname"
>$result</TT
> will be:
       <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>Array
(
    [event] =&#62; SIGGRAPH
    [city] =&#62; San Francisco
    [state] =&#62; CA
)</PRE
></TD
></TR
></TABLE
>
      </P
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     See also <A
HREF="function.extract.html"
><B
CLASS="function"
>extract()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.asort.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.count.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>asort</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.array.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>count</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>