Hey I have the following code which I’m using to isolate the a b c variables to use in the quadratic formula.
$equation = '-5x^2–3x+4';
$pattern = '/(?:^|[^\^])((?:\- *)?\d+)/';
preg_match_all($pattern, $equation, $pieces);
if (substr($equation, 0) == 'x')
{
$pieces_final[0][0] = 1;
$pieces_final[0][1] = $pieces[0][0];
$pieces_final[0][2] = $pieces[0][1];
}
else
{
$pieces_final = $pieces;
}
print_r($pieces_final);
and it’s not working, it’s showing a weird ascii character in replace of the negative sign infront of the three, I really have no clue what could be wrong.
That’s not a negative sign.