Advertisement
NathanF

JSON question

Nov 10th, 2011
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. function people_profile() {
  2.     $print = "gorilla test";
  3.     $fileName = "/opt/lampp/htdocs/wordpress/wp-content/themes/black-green/bios.json";
  4.     $people = json_decode(file_get_contents($fileName));
  5.    
  6.     //If I don't have nested objects, then this works:
  7.     //$print .= $people->name;
  8.     //When I do have nested objects, I can't just string pointers like this:
  9.     $print .= $people->Person->name;
  10.     //So, how do I get the desired effect?
  11.  
  12.     return $print;
  13. }
  14.  
  15. bios.json:
  16. { "Person": {
  17. "name":"Nathan"}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement