"Dog", "c" => "Horse");extract($my_array); // bbs.it-home.orgecho "\$a = $a; \$b = $b; \$c = $c";?>输出结果:$a">
当前位置:Gxlcms > PHP教程 > PHPextract()函数用法举例

PHPextract()函数用法举例

时间:2021-07-01 10:21:17 帮助过:21人阅读

  1. //导出数组为变量
  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. ?>

输出结果: $a = Cat; $b = Dog; $c = Horse

例2,使用全部参数:

  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. ?>

输出结果: $a = Original; $b = Dog; $c = Horse; $dup_a = Cat;

人气教程排行