Php:extract () function

Source: Internet
Author: User

Because the variables of the controller in Phpcms do not need to assgin the value into the template. All extract () functions become useful! Now let's take a look at his simple usage:

Definition and usage
The extract () function imports variables from an array into the current symbol table.
The function uses the array key name as the variable name , using the array key value as the variable value . For each element in the array, a corresponding variable is created in the current symbol table.
The second parameter type is used to specify how the extract () function treats conflicts when a variable already exists and the element with the same name in the array.
The function returns the number of variables that were successfully imported into the symbol table.

1<?PHP2 $a= "Dog";3 $my _array=Array("A" and "Apple", "b" = "pear", "C" and "banana");4 5 Extract($my _array, Extr_prefix_same, "ANI");6 7 Echo"\ $a =$a; \ $b =$b; \ $c =$c; \ $ani _a =$ani _a";8?>

Output:

$a = dog;

$b = pear;

$c = Banana;

$ani _a = dog;

Php:extract () function

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.