Przypuscmy ze mam $rownanie = "sin(40) + cos(30) * tan(20)"
jak powinna wyglada formula preg_math_all() aby uzyskac tablice :
[0][0] = sin
[0][1] = 40
[1][0] = cos
[1][1] = 30
[2][0] = tan
[2][1] = 20
?
<?php $rownanie = \"sin(40) + cos(30) * tan(20)\"; } ?>
<?php function kameleon_math($equation) { $allowed = Array('sin', 'cos', 'tan', 'pi', 'log', 'pow', 'sqrt', 'min', 'max', 'round', 'floor', 'abs'); foreach($matches[1] as $key => $current) { { { return \"Nieznane wyrazenie : $current\"; } else { $from = $matches[0][$key]; $value = $matches[2][$key]; switch($current) { case 'ctg' : $to = \"1/tan($value)\"; break; case 'dsin' : $to = \"sin(deg2rad($value))\"; break; case 'dcos' : $to = \"cos(deg2rad($value))\"; break; case 'dtan' : $to = \"tan(deg2rad($value))\"; break; case 'dctg' : $to = \"1/tan(deg2rad($value))\"; break; case 'tg' : $to = \"tan($vakue)\"; break; case 'dtg' : $to = \"tan(deg2rad($value))\"; break; } } } } return $math_result; } ?>