Array function Library: compact

Source: Internet
Author: User
Keywords compact php Chinese function manual array function library
Tags aliyun array array function library function function library html http name

Compact

(PHP4)

Compact---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Create an array containing variables and their values

Syntax: Array compact (string VarName | array varnames, [...]);

Description:

This function takes a number of variable arguments, each variable can be a string containing the name of the variable or the array name of the variable, and the array can contain the array name of the other variable.

This function looks for the variable name in the symbol table and adds it to the output array so that the name of the variable becomes the index value and the content of the variable becomes the value of the index value, which, in contrast to extract (), returns the output array.

Example:

<?php

$city = "San Francisco";

$state = "CA";

$event = "SIGGRAPH";

$location _vars = Array ("City", "state");

$result = Compact ("event", $location _vars);

?>

After that, $result will be array ("event" => "SIGGRAPH", "City" => "San Francisco", "state" => "CA")

Reference: Extract ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.