doufan1363 2014-05-25 19:14
浏览 41
已采纳

从PHP中的Json String返回一个结果[重复]

This question already has an answer here:

hi im trying to return 1 set of array from a json string in my code from searching nas i would like to show the data associated with that name. Any suggestions would be great .. thanks

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

//echo $_GET['urlname'];

$json_string =    file_get_contents("http://192.168.1.104/testing_JSON/newjson.json");
$parsed_json = json_decode($json_string, true);
$parsed_json = $parsed_json['contacts'];

for(var i = 0; i < $parsed_json.length; i++)
{
if($parsed_json[i].$parsed_json.name == 'nas')
{
 return $parsed_json[i].$parsed_json.name;
}
}
?

im getting a white screen with the above code.

thanks

</div>
  • 写回答

1条回答 默认 最新

  • donglan6777 2014-05-25 19:16
    关注

    Use echo instead of return. Return doesn't print anything.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料