如何为多个查询输出正确的结果

时间:2017-11-05 09:07:23

标签: php output

在查询中,我有多个输出的价格和p

例如

xmlns="https://www.w3.org/1999/xhtml"

如何根据每个 $price = 100; $p = 7; $price = 50; $p = 3; $price = 200; $p = 2; $price = 10; $p = 10; $price += $price * $p; echo $price; 计算每个$price

3 个答案:

答案 0 :(得分:1)

试试这个:

 $total = '';

 $price = 100;
 $p = 7;
 $total += $price*$p; // $total = 700
 $price = 50;
 $p = 3;
 $total += $price*$p; // $total = 850
 $price = 200;
 $p = 2;
 $total += $price*$p; // $total = 1250
 $price = 10;
 $p = 10;
 $total += $price*$p; // $total = 1350
 echo $total;

答案 1 :(得分:-1)

感谢所有您的影响,这修复了我的错误示​​例

 $price = "100";
 $p = "2";
 $price = "200";
 $p = "2";
 $price = "50";
 $p = "4";
 $price = "400";
 $p = "2";
 $price = $price * $p;
 $price = $price + $price;
 echo "$price";

答案 2 :(得分:-1)

(可选)如果将值存储在数组

private doPrompt(dishName) {
    this.prompt.displayPrompt()
        .then((response) => {
            console.log(response);
            // do some stuff because the accept button has tapped
            this.navCtrl.pop();
        }).catch((e) => {
            throw new Error('sth went wrong');
        });
}