Array Function Library: Extract

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

Extract

(PHP3 >= 3.0.7, PHP4)

Array_extract---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Entering variables from an array into a symbol table

Syntax: void extract (array var_array, int [extract_type], string [prefix]);

Description:

This function from an array input variable to the current symbol table, which takes an array Var_array and treats the index value as the variable name, and the value as the variable value, which sets the key/value pairs to a variable in the current symbol table to Extract_ Type and prefix are the conditions.

Extract () examines the existing variables, which, by parameter extract, determine how they are handled during collisions, which can be one of the following values:

Extr_overwrite

If a collision occurs, the existing variables are overwritten.

Extr_skip

If a collision occurs, it does not cover existing variables.

Extr_prefix_same

If a collision occurs, the parameter prefix is added to the top of the word to become a new variable.

Extr_prefix_all

Add parameters to the capital of all variables prefix

If no parameter extract_type is specified, the extr_overwrite is used.

Note: Parameter PREFIX is required when Extract_type is Extr_prefix_same or Extr_prefix_all.

Example:

<?php

/* Suppose that $var _array is a array returned from Wddx_deserialize * *

$size = "SCM";

$var _array = Array ("Color" => "blue", "Size" => "medium", "shape" => "sphere");

Extract ($var _array, Extr_prefix_same, "WDDX");

Print "$color, $size, $shape, $wddx _size\n";
?>

The example above will produce:

Blue, SCM, sphere, medium.

$size does not cover the past because we have specified extr_prefix_same, and the results in $wddx_size have been established, and if Extr_skip is used, $wddx_size will not be established, if Extr_overwrite is used $ The value of size is medium, and if you use Extr_prefix_all there will be a new variable named $wddx_color, $wddx _size, and $wddx_shape.

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.