I want to set a function to read the basic configuration information (array), but I don't know how to set it to deal with various arrays.
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-warning", "not delivered "),
"2" => array ("label-primary", "delivered "),
"0" => array ("label-default", "canceled "),
"3" => array ("label-success", "completed "),
"4" => array ("label-danger", "refund "),
"5" => array ("label-info", "address confirmation "),
"6" => array ("label-info", "rare goods "),
);
);
}
How can I set this function to cope with various arrays, mainly to read array values?
Reply to discussion (solution)
What are the meanings of your $ name and $ value parameters? What is the intention of the function to return?
Orderstatus [1] [0] = label; orderstatus [1] [1] = label-warning; orderstatus [1] [2] = not delivered;
Orderstatus [2] [0] = label; orderstatus [1] [1] = label-primary; orderstatus [1] [2] = delivered;
...............................
This is the way to get the values in the corresponding array.
????
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-warning", "not delivered "), "2" => array ("label-primary", "shipped"), "0" => array ("label-default", "canceled "), "3" => array ("label-success", "completed"), "4" => array ("label-danger", "refund "), "5" => array ("label-info", "address confirmation"), "6" => array ("label-info ", "Missing goods"),); if (isset ($ web_data_init [$ name] [$ value]) {return $ web_data_init [$ name] [$ value];} else {return ''; }}$ data = get_base_data (" orderstatus "," 1 "); if (is_array ($ data) {print_r ($ data );} else {echo $ data ;}