T
T
ThreegunD2018-10-09 15:53:58
PHP
ThreegunD, 2018-10-09 15:53:58

Are there ready-made "compute from string" libraries?

Hello.
Please tell me the library (if any) that calculates an expression from a string, taking into account not only numbers, but also strings.
With precedence of signs and brackets.
For example $str = "Amount + (2 - 1) + something + 2+2*2+100";
Would output "Amount1ofsomething106"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xmoonlight, 2018-10-09
@xmoonlight

echo "Количество " . (2 - 1) . " чего-то " . (2+2*2+100);

You can also use a simple library: matex

N
Nikolai Konyukhov, 2018-10-09
@heahoh

https://gist.github.com/ircmaxell/1232629
I think we can take this as a basis and modify it to fit the requirements

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question