<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >compact</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual PHP" HREF="index.html"><LINK REL="UP" TITLE="Array - funcþii" 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-2"></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" >Manual PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.asort.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.count.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.compact" ></A >compact</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN7148" ></A ><P > (PHP 4 , PHP 5)</P >compact -- Create array containing variables and their values </DIV ><DIV CLASS="refsect1" ><A NAME="AEN7151" ></A ><H2 >Description</H2 >array <B CLASS="methodname" >compact</B > ( mixed varname [, mixed ...])<BR ></BR ><P > <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 > 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 > Any strings that are not set will simply be skipped. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN7170" ></A ><P ><B >Exemplu 1. <B CLASS="function" >compact()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> $city = "San Francisco";<br />$state = "CA";<br />$event = "SIGGRAPH";<br /><br />$location_vars = array ("city", "state");<br /><br />$result = compact ("event", "nothing_here", $location_vars);</font> </code></TD ></TR ></TABLE ><P > After this, <VAR CLASS="varname" >$result</VAR > will be: <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> Array<br />(<br /> [event] => SIGGRAPH<br /> [city] => San Francisco<br /> [state] => CA<br />)</font> </code></TD ></TR ></TABLE > </P ></DIV ></TD ></TR ></TABLE > </P ><P > 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" >Înapoi</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Acasã</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.count.html" ACCESSKEY="N" >Înainte</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" >Sus</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >count</TD ></TR ></TABLE ></DIV ></BODY ></HTML >