PHP compact函数

1 $firstname = "Peter";
2 $lastname = "Griffin";
3 $age = "41";
4 
5 $data = compact("firstname", "lastname", "age");
6 
7 print_r($data);
8 
9 运行结果:Array ( [firstname] => Peter [lastname] => Griffin [age] => 41 )

创建一个包含变量名和它们的值的数组

posted @ 2018-04-18 09:37  HUI9527  阅读(442)  评论(0编辑  收藏  举报