楽天API ヒアドキュメント内でnumber_formatが効かない時の対処方法




楽天APIを使っていて不具合が出たので対処方法をメモしておきます。

楽天商品APIで商品価格は

「$itemPrice = ($item->itemPrice);」

で取得できますが、

3桁毎にカンマをつけたい場合

「$itemPrice = number_format($item->itemPrice);」

と記述すると、環境によっては何も表示されなくなる場合があります。

解決方法として

$itemPrice = number_format((int)$item->itemPrice);

のように(int)を付ければうまく表示されます。




人気記事一覧


関連記事一覧

This entry was posted in 楽天API and tagged , , , , . Bookmark the permalink.

コメントは受け付けていません。