本帖最后由 zl2727 于 2013-12-10 18:08:23 编辑

解决方案 »

  1.   

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

  2.   

    这个是 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" } } 
      

  3.   

    我把 $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/" ) );
      也是正确的 前台可以接到值 result不是空  是不是数据库的问题 您说的 在读数据的时候也可以转 怎么转UTF-8? 我找了好久
    我的表是GBK的表  我新建了一个UTF-8的表也不行
      

  4.   

    $a 在函数中,你调用了吗。函数的return 也不对吧?
      

  5.   

    谢谢 大神们的支持 由于小弟疏忽  在AJAX请求时 路径写错 其他啥问题都没有  结贴!!!
      

  6.   

    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);
    {"status":"1","result":[{"id":"1102444","title":"\u4e8b\u5b9e\u4e0a","goodstitle":"\u4e8b\u5b9e\u4e0a","price":"429.0","imgurl":".jpg","goodsurl":"\/","brandtitle":"44444","brandurl":"_share\/"},{"id":"1102444","title":"\u8d4c\u4e1c\u9053\u7684","goodstitle":"\u8d4c\u4e1c\u9053\u7684","price":"429.0","imgurl":"0.jpg","goodsurl":"2444\/","brandtitle":"7777","brandurl":"share\/"}],"moreUrl":"x"}不会有问题的,检查你每次的查询条件是否正确!
    没有查询到,自然就是空数组