复制代码 代码如下: <?php function getDerivativeByFormulaAndXDATA($formula, $x_data){ $xArray = explode(“+”, $formula); $Derivative = 0; foreach ($xArray as $x_record) { $tmpArray = explode(“x^”, $x_record); if(count($tmpArray) == 2){ $coefficient = $tmpArray[0]==””?1:$tmpArray[0]; $exp = $tmpArray[1]; }