【发布时间】:2013-08-23 16:54:11
【问题描述】:
我有一个 OpenCart VQMod,它目前按字符计算字符串长度和费用。它工作得很好,但我需要它按照以下规则收费:
30-45 个字符:$8.50
超过 46 个字符:$12.00
编辑: 到目前为止,这个模块将字符串长度乘以每个字符的固定价格,但我需要它只收取 30-45 个字符的固定价格 8.50 美元,或 46 个以上字符的 12 美元。谁能帮我修改以下PHP?我在这里粘贴整个文件。非常感谢您到目前为止的回复。我非常感谢社区的帮助。
编辑2:删除了不必要的代码,只显示字符串长度药水。
//Q: Option Price By Character
$optprice = '';
$optprefix = '';
if ($option_query->row['type'] == 'text' || $option_query->row['type'] == 'textarea') {
if (strlen($option_value)) {
$optprice = (strlen($option_value) * $option_query->row['price_per_char']);
$optprefix = '+';
$option_price += $optprice;
【问题讨论】:
-
你的代码有什么具体问题?
-
@StephenTG,我需要逻辑方面的帮助,特别是这部分://Q: Option Price By Character $optprice = ''; $optprefix = ''; if ($option_query->row['type'] == 'text' || $option_query->row['type'] == 'textarea') { if (strlen($option_value)) { $optprice = (strlen ($option_value) * $option_query->row['price_per_char']); $optprefix = '+'; $option_price += $optprice; } }
标签: php count character opencart strlen