2012-02-28 58 views
0

嘿,我有下面的代码,我用它来隔离二次公式中使用的bc变量。负号被损坏php

$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); 

和它不工作,它显示一个奇怪的ASCII字符替换中盈三的负号的,我真的不知道该怎么可能是错的。

回答

2

这不是一个负面的迹象。

>>> hex(ord(u'–')) 
'0x2013' 
>>> unicodedata.name(u'–') 
'EN DASH'