Ejemplo: php redondeado al grado de tiempo más cercano con la calculadora de ms
For people interest in Differential Equations, I've done a function that receive a string like: x^2+x^3 and put it in
2x+3x^2 witch is the differantial of the previous equation.
In the code there is one thing missing: the $string$i is often going outOfBound (Uninitialized string offset: 6 in...)
if your error setting is set a little too high... I just dont know how to fix this.
So there is the code for differential equation with (+ and -) only:
functiondifferentiel($equa)$equa=strtolower($equa);echo"Equation de depart: ".$equa."
";$final="";for($i=0;$i<strlen($equa);$i++)//Make a new string from the receive $equaif($equa$i=="x"&&$equa$i+1=="^")$final.=$equa$i+2;$final.="x^";$final.=$equa$i+2-1;elseif($equa$i=="+"////Manage multiplication add in the previous string $final//$finalMul="";for($i=0;$i<strlen($final);$i++)if(is_numeric($final$i)&&$final$i+1=="*"&&is_numeric($final$i+2))$finalMul.=$final$i*$final$i+2;elseif($final$i=="*")continue;elseif(is_numeric($final$i)&&$final$i+1!="*"&&$final$i-1=="*")continue;else$finalMul.=$final$i;echo"equa final: ".$finalMul;?>
I know this is not optimal but i've done this quick :)
If you guys have any comment just email me.
I also want to do this fonction In C to add to phpCore maybe soon...
Patoff
valoraciones y comentarios
Si te gusta la idea, tienes el poder dejar una reseña acerca de qué te ha impresionado de este tutorial.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)