Home > Article > Backend Development > 字符串转化作数字?
字符串转化为数字???
今天遇到个比较奇怪的现象,很可能是我储备还不够吧,包含引号的数字的字符串转化为数字时出现了问题
<br />"1000","902865066306","02865066306","SIP Phone","IP Trunk","","trunk20","ON2OFF","1333230069","1333230072","1333230134","65","62","Connected"<br />
<br />$arr = '"1000","902865066306","02865066306","SIP Phone","IP Trunk","","trunk20","ON2OFF","1333230069","1333230072","1333230134","65","62","Connected"';<br />$arr = explode(',',$arr);<br />print_r($arr);<br />
<br />Array<br />(<br /> [0] => "1000"<br /> [1] => "902865066306"<br /> [2] => "02865066306"<br /> [3] => "SIP Phone"<br /> [4] => "IP Trunk"<br /> [5] => ""<br /> [6] => "trunk20"<br /> [7] => "ON2OFF"<br /> [8] => "1333230069"<br /> [9] => "1333230072"<br /> [10] => "1333230134"<br /> [11] => "65"<br /> [12] => "62"<br /> [13] => "Connected"<br />)<br />
<br />echo $arr[8] + 0; //结果为0<br />
<br />$num = "1333230069";<br />echo $num+0;//1333230069<br />
$arr = '"1000","902865066306","02865066306","SIP Phone","IP Trunk","","trunk20","ON2OFF","1333230069","1333230072","1333230134","65","62","Connected"';<br />$t = json_decode("[$arr]");<br />print_r($t);Array