1、compact() 函数创建包含变量名和它们的值的数组。<?php
$firstname = "Bill";
$lastname = "Gates";
$age = "60";
$result = compact("firstname", "lastname", "age")
;
print_r($result);
?>2、extract() 函数从数组中将变量导入到当前的符号表。
<?php
$a = "Original";
$my_array = array("a" => "Cat","b" => "Dog", "c" => "Horse");
extract($my_array);
echo "\$a = $a; \$b = $b; \$c = $c";
?>
原文地址:https://www.cnblogs.com/zxr07/p/8125887.html
时间: 2024-10-29 10:05:15