I’m trying to create a calculation based on the values of the array – imagine the following array:
$values = array(9, +, 10, *, 7)
I thought about the following approach:
$result = number_format(implode(' ', $values), 2)
but this obviously doesn’t work.
Any idea how could this be achieved?
You could use
eval()…If any portion of this array came from user input, you should filter the array to ensure it only has numbers and valid operators.