<?php //compact 将变量组合为数组 $key_1 = "val_1"; $key_2 = "val_2"; $data = array('$key_3'=>'val_3','$key_4'=>'val_4'); $arr_n =compact('key_1','key_2','data'); echo "compact: "; //extract根据键名导出变量 echo "extract: "; $arr_str = array('key_a'=>'val_a','key_b'=>'val_b','key_arr'=>array('1','2','3')); extract($arr_str); var_dump($key_a); var_dump($key_b); var_dump($key_arr); // list(只作用于索引数组)用来取出数据。可只取出部分数据,如只取出前两个 echo "list: "; $arr_data =array('data_1','data_2','data_3','data_4'); list($v1,$v2)=$arr_data; var_dump($v1); var_dump($v2); //list也可取变量放在数组指定位置中 list($data_res['0'],$data_res['5'])=$arr_data; var_dump($data_res); ?>