array("GBP","USD","JPY","EUR","CAD","CNY"), "count"/> array("GBP","USD","JPY","EUR","CAD","CNY"), "count">
首頁 > 後端開發 > php教程 > 读取数组的有关问题

读取数组的有关问题

WBOY
發布: 2016-06-13 12:17:14
原創
929 人瀏覽過

读取数组的问题
我想设置一个函数用来读取基本配置资料(数组),但是不知道怎么设置才能应对各种数组
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 />
登入後複製

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板