配列の読み取りに関する問題
基本的な構成データ (配列) を読み取る関数を設定したいのですが、さまざまな配列を処理するための設定方法がわかりません
function get_base_data($name,$value) {
$web_data_init=array(
"通貨"=>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("ラベル ラベル警告","出荷されていません"),
"2" =>array("ラベル ラベル-プライマリ","出荷済み"),
"0" => ; array("label label-default","Cancelled"),
"3" =>array("label label-success","Completed"),
"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 />