Home > Backend Development > PHP Tutorial > PHP extract() function usage example

PHP extract() function usage example

WBOY
Release: 2016-07-25 08:57:44
Original
1355 people have browsed it
  1. //Export the array as a variable
  2. $a = 'Original';
  3. $my_array = array("a" => "Cat","b" => "Dog", "c" => "Horse");
  4. extract($my_array); // bbs.it-home.org
  5. echo "$a = $a; $b = $b; $c = $c";
  6. ?>
Copy the code

Output results: $a = Cat; $b = Dog; $c = Horse

Example 2, using all parameters:

  1. $a = 'Original';

  2. $my_array = array("a" => "Cat","b" => "Dog", " c" => "Horse");

  3. extract($my_array, EXTR_PREFIX_SAME, 'dup');

  4. echo "$a = $a; $b = $b; $c = $c; $dup_a = $dup_a;";

  5. ?>

Copy the code

output result: $a = Original; $b = Dog; $c = Horse; $dup_a = Cat;



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template