function gtou($s) { return iconv('gbk', 'utf-8', $s); }$proquery ="select * from pro where typeid='".$id."' order by corank asc"; $dsql->SetQuery($proquery); $dsql->Execute(); $a=array(); while($row = $dsql->GetArray()) { $a[]= array_map('gtou', $row); } $res = array( "status" => "1", "result" => $a, "moreUrl" => $moreurl, ); echo json_encode($res);
用 var_dump 输出
print_r($a); 看看
Array ( [0] => Array ( [id] => 1 [goodstitle] => 琛ユ按娑???? ???寰?ソ 寰?ˉ姘? ?????脊?? [goodsurl] => http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg [brandtitle] => 缇???? [brandurl] => http://www.ecoo.com.cn/dsadasdas/ [imgurl] => http://www.ecoo.com.cn/sadas213/ [price] => 59.9 ) [1] => Array ( [id] => 2 [goodstitle] => 琛ユ按娑??222 [goodsurl] => http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg [brandtitle] => 缇?222 [brandurl] => http://www.ecoo.com.cn/dsadasdas/ [imgurl] => http://www.ecoo.com.cn/sadas213/ [price] => 59.9 ) )
这个是 var_dump 结果
array(2) { [0]=> array(7) { ["id"]=> string(1) "1" ["goodstitle"]=> string(54) "琛ユ按娑???? ???寰?ソ 寰?ˉ姘? ?????脊??" ["goodsurl"]=> string(70) "http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg" ["brandtitle"]=> string(9) "缇????" ["brandurl"]=> string(33) "http://www.ecoo.com.cn/dsadasdas/" ["imgurl"]=> string(32) "http://www.ecoo.com.cn/sadas213/" ["price"]=> string(4) "59.9" } [1]=> array(7) { ["id"]=> string(1) "2" ["goodstitle"]=> string(15) "琛ユ按娑??222" ["goodsurl"]=> string(70) "http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg" ["brandtitle"]=> string(6) "缇?222" ["brandurl"]=> string(33) "http://www.ecoo.com.cn/dsadasdas/" ["imgurl"]=> string(32) "http://www.ecoo.com.cn/sadas213/" ["price"]=> string(4) "59.9" } }
不会的,$a 不为空,就不会输出空数组
版主 您可以加下我吗? 我给您发测试连接 您看看
我把 $a 换成
$a = array ( array( "id" => "1102444","title"=>"事实上","goodstitle"=>"事实上","price"=>"429.0","imgurl"=>".jpg","goodsurl"=>"/","brandtitle"=>"44444","brandurl"=>"_share/" ), array( "id" => "1102444","title"=>"赌东道的","goodstitle"=>"赌东道的","price"=>"429.0","imgurl"=>"0.jpg","goodsurl"=>"2444/","brandtitle"=>"7777","brandurl"=>"share/" ) );
$a 在函数中,你调用了吗。函数的return 也不对吧?
谢谢 大神们的支持 由于小弟疏忽
在AJAX请求时 路径写错
其他啥问题都没有
结贴!!!
function gtou($s) { return iconv('gbk', 'utf-8', $s); }$a = array ( array( "id" => "1102444","title"=>"事实上","goodstitle"=>"事实上","price"=>"429.0","imgurl"=>".jpg","goodsurl"=>"/","brandtitle"=>"44444","brandurl"=>"_share/" ), array( "id" => "1102444","title"=>"赌东道的","goodstitle"=>"赌东道的","price"=>"429.0","imgurl"=>"0.jpg","goodsurl"=>"2444/","brandtitle"=>"7777","brandurl"=>"share/" ) );foreach($a as $r) $t[] = array_map('gtou', $r);$moreurl = 'x';$res = array( "status" => "1", "result" => $t, "moreUrl" => $moreurl, ); echo json_encode($res);