日期:2014-05-17 浏览次数:20562 次
$nodeAry=array();
while($row=mssql_fetch_array($rs)){
$description=strstr("//","",$row['description']);
array_push($nodeAry,'{"fchrItemID":"'.$row["fchrItemID"].'","fchrItemTypeID":"'.$row["fchrItemTypeID"].'","fchrItemName":"'.$row["fchrItemName"].'","flotQuotePrice":"'.$row["flotQuotePrice"].'","description":"'.trim($description).'","fdtmLastModifyTime":"'.$row["fdtmLastModifyTime"].'","sales_volume":"'.$row["sales_volume"].'"}');
}
$tbstr=implode(',',$nodeAry);
?>{"table":[<?=$tbstr;?>]}
header("Content-Type:text/html; charset=utf-8");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $remoteAPIBasePath . "sync2shop_api/item.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
curl_close($ch);
$obj=json_decode(iconv("gb2312","utf-8",$output));
var_dump( $obj);
//$obj=json_decode($output);
$rscount=count($obj->table);
$han=fopen("debug.php","a");
fwrite($han,$output."---------".$rscount);
fclose($han);
$s = '{"a":"我的","b":"数据","c":["是从远程数据库","取的"],"d":"难道会有影响吗?"}';
$s = iconv('gbk', 'utf-8', $s);
print_r(json_decode($s));
stdClass Object
(
[a] => 我的
[b] => 数据
[c] => Array
(
[0] => 是从远程数据库
[1] => 取的
)