-
- //给定变量
- $city = "菏泽";
- $province = "山东省";
- $project = "PHP Program";
- $location_vars = array("province", "city");
- //创建数组
- $result = compact("project", "nothing", "location_vars");
- print_r($result);
- ?>
复制代码
在以上的程序中,因为并不存在名字是"nothing"的变量,因此程序的输出结果如下:
Array
(
[project] => PHP Program
[province] => 山东省
[city] => 菏泽
)
|