Here's a straight-forward example doing the two things that you ask for (see inline comments).
$json = '[{"location":"USA","email":"[email protected]","sex":"male","age":"Unkown","other":null,"profile":{"net":["55","56"],"networks":[{"site_url":"http://site.com","network":"test","username":"mike"},{"site_url":"http://site.com/2","network":"test2","username":"mike2"}]},"name":"Mike Jones","id":111}]';
// "Decode" JSON into (dumb) native PHP object
$data = json_decode($json);
// Get the first item in the array (there is only one)
$item = $data[0];
// Loop over the profile.networks array
foreach ($item->profile->networks as $network) {
// echos out the site_url,network, and user
echo "site_url = " . $network->site_url . PHP_EOL;
echo "network = " . $network->network . PHP_EOL;
echo "user = " . $network->username . PHP_EOL;
}
// Get "name" at the end
echo "name = " . $item->name . PHP_EOL;
It should output (if you're viewing as HTML, it will be munged onto one line… don't output as HTML).
site_url = http://site.com
network = test
user = mike
site_url = http://site.com/2
network = test2
user = mike2
name = Mike Jones