我遇到以下問題。 我需要以下根據用戶(貨幣)設置的環境中顯示:將大括號替換爲內部變量
$sMyPromotion = 'this offer starts at {5000}';
// 5000 is the value in my default currency (euros for example) and
// needs to be converted to the user currency
// so I have a function that converts : convertRate($Price, $aCurrency)
// that returns for example: 6000 USD.
但我堅持就如何採取什麼是大括號和方括號之間,並通過返回的數據進行替換通過convertRate因爲我不舒服的正則表達式,預浸...
我需要的東西呢:
$sOccurency = what is between curly brackets and the brackets;
$sMyPromotion = Replace $sOccurency with convertRate($sOccurency, $aCurrency);
所以在這個例子: $ sMyPromotion = '此優惠開始時間:{} 5000' ;
預期結果: $ sMyPromotion ='此優惠始於6000 $';
大括號總是平衡的嗎?它們也可以嵌套嗎? – anubhava
OP,請不要在您的問題標題中放置標籤。 –