1
I have to make a calculation based on two things:
1 - The value that the user informs
2 - The basic account I have registered in the bank
I have the base account: 5149.3074*{{INPUT}} (0.0001)-5129.6906
Where is {{INPUT}} is the value that the user informs in the input, until then I can replace {{INPUT}} by the value with the function str_replace
. The biggest problem is in "^" which means "Power" and for that PHP needs a function to calculate. What I need is to take the value that is after the "^" between parentheses.
How can I do that ?
Thank you @Francisco .. Your Regex worked perfectly. Could you explain to me in detail what each item of your regex does ? (only if you really succeed)
– Alisson Acioli
There is a site that generates the regex for you, just know the basics. PHP Live Regex
– Francisco
could you help me one more time? I have one last calculation that is like this (({{price}}+625.5175)/637.3620) 5963.7532 and the power is now at the end and without parentheses, which would be the Regex to take only the values ?
– Alisson Acioli
Would look like this:
preg_match("/[\^](.*)\./", $conta, $valor);
– Francisco
until it works only that it does not take the decimals, IE, it takes only 5963 and not 5963.7532
– Alisson Acioli
Ahh, I thought the point was multiplying kkk, brisei. So, do
preg_match("/[\^](.*)/", $conta, $valor);
.– Francisco
It worked, now only gave a blow the first you helped me because you had to have the parentheses to sequence the right calculation. The formula is: (5149.3074({{INPUT}} (0.0001)))-5129.6906* And Regex is bringing in some parentheses.
– Alisson Acioli
To take the most important (counted with the parentheses) do so:
preg_match("/\(([0-9.]+)\)/", $conta, $valor);
If this account always changes, I recommend that you make an algorithm to suit.– Francisco