CMS内のmagentoを介して提供される任意のテキストがあり、
取得されるテキストには、価格が含まれている場合があります。たとえば
配信テキスト
200 ユーロ以上のご注文は無料でお届けします。200 ユーロ未満の注文には 10 ユーロの手数料がかかります。重量物は別途料金が発生する場合がございます。
価格の出現ごとに置き換えるにはどうすればよいので、上記の場合は変更します
€200
€10
€200
現在使用されている通貨に基づいて、これらの価格を置き換えたいと考えています。
$fromCur = 'EUR'; // currency code to convert from
$toCur = 'USD'; // currency code to convert to
$toCurrencyPrice = Mage::helper('directory')->currencyConvert($fromCurrencyPrice, $fromCur, $toCur);
これは私が価格を変換する方法です。唯一のことは、テキスト内で価格を見つける方法がわからないことです
これが私がこれまでに試したことです
//the text to search
$text = 'Orders over €200 are delivered Free Of Charge. €10 charge for orders under €200. There may be additional charges for heavy goods.';
$matches = array();
//find a price with a euro symbol
preg_match_all("/€[0-9]+/", $text, $matches);
$ints = array();
$counter = 0;
//remove the euro symbol
foreach ($matches[0] as $match) {
//echo substr( $match,6) . '<br/>';
$ints[$counter] = substr( $match,6);
$counter++;
}
//now i know i have to convert it to my price, but my issue is, how do i now replace new values, with the old values inside the $ text varaible
$ints (ユーロ記号のない価格) の要素を使用して、見つかった一致を変更したいとしましょう。どうすればいいですか?