我試圖返回基於$ ProductCurrency的貨幣符號和貨幣代碼,其值是數組中第一列中的貨幣之一,這是我擁有的代碼;從PHP中的數組返回匹配值
<?php
$currency_symbols = array (
array ('australian dollar','$','aud'),
array ('brazilian real','R$','brl'),
array ('canadian dollar','$','cad'),
array ('czech koruna','Kč','czk'),
array ('danish krone','kr','dkk'),
array ('euro','€','euro'),
array ('pound sterling','£','gbp'),
array ('hong kong dollar','$','hkd'),
array ('hungarian forint','Ft','huf'),
array ('israeli new sheqel','₪','ils'),
array ('japanese yen','¥','jpy'),
array ('malaysian ringgit','RM','myr'),
array ('mexican peso','$','mxn'),
array ('norwegian krone','kr','nok'),
array ('new zealand dollar','$','nzd'),
array ('philippine peso','₱','php'),
array ('polish zloty','zł','pln'),
array ('russian ruble','руб','rub'),
array ('singapore dollar','$','sgd'),
array ('swedish krona','kr','sek'),
array ('swiss franc','CHF','chf'),
array ('thai baht','฿','thb'),
array ('turkish lira','₤','try'),
array ('taiwan new dollar','NT$','twd'),
array ('us dollar','$','usd'),
);
$ProductCurrency = 'australian dollar';
$CurrencySymbol = $currency_symbols[$ProductCurrency][1];
$CurencyCode = $currency_symbols[$ProductCurrency][2];
?>
但代碼爲$ CURRENCYSYMBOL返回沒有爲我所期待$
和$貨幣代碼爲此我要求以「澳元」,變量,我缺少什麼?
什麼'get_field'?你使用WP? –
*「我錯過了什麼?」* - 更多(相關)代碼。同時,看看http://php.net/manual/en/function.error-reporting.php是否返回任何內容。 –
是的,它是WordPress,get_field('product_currency')返回一個用戶選擇,它基於與數組中第1列相同的列表。 '澳大利亞元',或'巴西真實',這工作正常,所以你可以假設$ ProductCurrency =澳大利亞元。 – Naz