如何在Php中编码这个公式?

时间:2018-02-14 04:45:10

标签: php math formula equation-solving

我试图在php中表示这个公式,但值不正确可能我有一些问题将公式转换为代码

p*|log(0.15*(m-2)|

1 个答案:

答案 0 :(得分:0)

let response = `EXECUTED @ 9.1539(3.0) was PARTIALLY FILLED @ 9.1531(3.0)     
EXECUTED @ 9.1539(3.0)
PARTIALLY FILLED @ 9.16(5.5)`;                                                                                                                          

response = response.split(/\n/);                                                                                                                            


for ( let resp of response ) {                                                
    resp = resp.replace(/[^@\(\d\.]/g, "");                                   
    resp = resp.replace(/\(/g, "*");                                          
    resp = resp.replace(/@/g, "+");                                           
    resp = resp.replace(/^\+/, "");                                                                                                                         
    resp = eval(resp);                                                        
    console.log(resp);                                                        
}                                                                             

如果它们是字符串,则将任何值转换为整数/浮点数/双精度。