while(strpos($ssc,”2017″)) {
echo ‘{“expect”:”‘.substr($ssc,strpos($ssc,”2017″),11).” “.'”,”opentime”:”‘.substr($ssc,strpos($ssc,”2017″)+50,18).” “.
‘”,”opencode”:”‘.
substr($ssc,strpos($ssc,”2017″)+107,1).” “.
substr($ssc,strpos($ssc,”2017″)+147,1).” “.
substr($ssc,strpos($ssc,”2017″)+187,1).” “.
substr($ssc,strpos($ssc,”2017″)+227,1).” “.
substr($ssc,strpos($ssc,”2017″)+267,1).’},’;
$ssc=substr($ssc,strpos($ssc,”2017”)+1700);
}
我做了一个while循环,但是最后一次循环不需要加最后的一个逗号,
怎么把最后一个逗号去掉!
回复讨论(解决方案)
$ssc = substr($ssc, 0, -1);
你做好贴出原始的串看看
$ssc = substr($ssc, 0, -1);这个放在那里啊
$a = ”;
while(strpos($ssc,”2017″)) {
$a .= ‘{“expect”:”‘.substr($ssc,strpos($ssc,”2017″),11).” “.'”,”opentime”:”‘.substr($ssc,strpos($ssc,”2017″)+50,18).” “.
‘”,”opencode”:”‘.
substr($ssc,strpos($ssc,”2017″)+107,1).” “.
substr($ssc,strpos($ssc,”2017″)+147,1).” “.
substr($ssc,strpos($ssc,”2017″)+187,1).” “.
substr($ssc,strpos($ssc,”2017″)+227,1).” “.
substr($ssc,strpos($ssc,”2017″)+267,1).’},’;
$ssc=substr($ssc,strpos($ssc,”2017”)+1700);
}
$a = substr($a,0,-1);
echo $a;