Reputation: 7
{
"Group": [
{
"name": "HolderOne",
"operators": [
{
"username": "ken",
"status": 3
},
.....etc.....
Hi all,
I've succesfully pulled data out of my JSON feed thanks the help on SO...but...scratching my head now.
By using print_r($obj->....)
I am able to extract all information from my feed BUT what I want to be able to do is...
From above, if the value of username is 'ken' then only display the associated status 3.
I think it could be using the value the print_r assigns each Array(?)
e.g. above would be [0]
- now I don't know what the value would be so can I grab the [n]
value for each username to display the status?
I am slightly outside my comfort zone here...not sure if it's a PHP or JSON problem for a start.
Thanks in advance for any help
Upvotes: 0
Views: 64
Reputation: 2676
Is this what you are looking for?
foreach($obj->Group as $group)
{
foreach($group->operators as $operator)
{
if($operator->username == "ken")
{
echo $operator->status;
}
}
}
Upvotes: 1