-3

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

Nasir Shiraz
  • 161
  • 1
  • 3
  • 15
  • You didn't showed any JSON string in your question. `192.168.1.104` is something different for most of us. Keep in mind, that we're not in the same local area network as you are. also try to create a self-contained example. – hakre May 25 '14 at 19:18
  • you are trying to use javascript syntax here. rtfm http://www.php.net/manual/en/language.types.array.php http://www.php.net/count – chiliNUT May 25 '14 at 19:20
  • http://php.net/foreach – hakre May 25 '14 at 19:20

1 Answers1

2

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

Alex
  • 4,674
  • 5
  • 38
  • 59