array("GBP","USD","JPY","EUR","CAD","CNY"), "count"/> array("GBP","USD","JPY","EUR","CAD","CNY"), "count">
Maison >développement back-end >tutoriel php >读取数组的有关问题
读取数组的问题
我想设置一个函数用来读取基本配置资料(数组),但是不知道怎么设置才能应对各种数组
function get_base_data($name,$value){
$web_data_init=array(
"currencies"=>array("GBP","USD","JPY","EUR","CAD","CNY"),
"country_D"=>array
(
"UK"=>"GBP",
"DE"=>"EUR",
"IT"=>"EUR",
"FR"=>"EUR",
"US"=>"USD",
"UK"=>"GBP",
"JP"=>"JPY",
"CA"=>"CAD",
"CN"=>"CNY",
),
"orderstatus"=>array(
"1"=>array("label label-warning","未发货"),
"2" =>array("label label-primary","已发货"),
"0" =>array("label label-default","已取消"),
"3" =>array("label label-success","已完成"),
"4" =>array("label label-danger","退款"),
"5" =>array("label label-info","地址确认中"),
"6" =>array("label label-info","少货"),
);
);
}
请问我这个函数要怎么设置,才能应对各种数组,主要是读取数组值
------解决思路----------------------
這樣嗎?
<br />function get_base_data($name,$value){<br /> $web_data_init=array(<br /> "currencies"=>array("GBP","USD","JPY","EUR","CAD","CNY"),<br /> "country_D"=>array(<br /> "UK"=>"GBP",<br /> "DE"=>"EUR",<br /> "IT"=>"EUR",<br /> "FR"=>"EUR",<br /> "US"=>"USD",<br /> "UK"=>"GBP",<br /> "JP"=>"JPY",<br /> "CA"=>"CAD",<br /> "CN"=>"CNY",<br /> ),<br /> "orderstatus"=>array( <br /> "1" =>array("label label-warning","未发货"),<br /> "2" =>array("label label-primary","已发货"),<br /> "0" =>array("label label-default","已取消"),<br /> "3" =>array("label label-success","已完成"),<br /> "4" =>array("label label-danger","退款"),<br /> "5" =>array("label label-info","地址确认中"),<br /> "6" =>array("label label-info","少货"), <br /> )<br /> );<br /><br /> if(isset($web_data_init[$name][$value])){<br /> return $web_data_init[$name][$value];<br /> }else{<br /> return '';<br /> }<br /><br />}<br /><br /><br />$data = get_base_data("orderstatus","1");<br />if(is_array($data)){<br /> print_r($data);<br />}else{<br /> echo $data;<br />}<br />