How to count the array?

Good hold days. I have an array:
Array
(
 [0] => 10
 [1] => +
 [2] => 10
 [3] => *
 [4] => 2
 [5] => +
 [6] => 10
)

Tell me in what ways it is possible to count. That would be respectively the multiplication first. Read about Polish notation but the examples on the php is not found. Thanks in advance.
July 8th 19 at 12:09
3 answers
July 8th 19 at 12:11
You need these values to calculate and js
echo "'; - Bernie commented on July 8th 19 at 12:14
here's the catch ;) as an option ideone.com/KYVRaH - Bernie commented on July 8th 19 at 12:17
: Thank you Oleg, with JavaScript, everything works as expected, though the task was different but this is a working version, thanks for the help) - Lindsay.Goldne commented on July 8th 19 at 12:20
July 8th 19 at 12:13
Specifically, in your case, and using eval
But this is a very dangerous design and better about it to forget
That's it, and I would like to do this without eval - Bernie commented on July 8th 19 at 12:16
July 8th 19 at 12:15
$arr = array (10,'+',10, '*', 2 , '+', 10);
$umn = array_search('*',$arr);
$umn_res = $arr[$umn-1] * $arr[$umn+1];
unset($arr[$umn-1]);
unset($arr[$umn+1]);
unset($arr[$umn]);
echo array_sum($arr)+$umn_res;

This decision only on multiplication and addition can this trailer to consider and other operations, but note that if 2 times to repeat the multiplication then the result is not correct you will need to use array keys instead of array-search and pass the result found key cycle and then think what to do with these figures. Food for thought gave then themselves))
The problem is that I need to read input data and how to convert them into a type as you describe from the array $arr I don't know. And multiplications can be many. - Bernie commented on July 8th 19 at 12:18
And what is your input data type ? - Bernie commented on July 8th 19 at 12:21
The task is this. Simple calculator. There is a function and input variable. This variable data is entered in the input string. We need these details to calculate. I decided that if I break the line into pieces as shown in the array above. The fact that you helped me solve last question) Then I can use them as something to do. Something like this. - Lindsay.Goldne commented on July 8th 19 at 12:24

Find more questions by tags PHP