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
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板