Jump to content

Help with a foreach loop issue from json source


mosb3rgler

Recommended Posts

Hey there folks,

Im trying to get a foreach loop working correctly from a json source epg heres my code:

https://pastebin.com/FjHj1EF6

Here is the current output, which.. while correct is only the first instance of these values i wanted using the foreach loop, i would love any tips on why my approach failed and to be pointed in the right direction.

While it has to be included:

$url = "https://mywebsite.fake/mlb.php?id={$arr['games'][0]["gamePk"]}";

this value isn't related to the assistance im asking for. that will work for my purposes later. but for now i just need to understand the issue with the foreach loop.

Thanks in advance for your thoughtful response.

mosb3rgler

Link to comment
Share on other sites

ahh i see what your saying now. but my question is how would it look when your factoring in multiple indexes with in games. because the way i have the foreach example setup im noting the initial index 0, so im not sure how to have it look to all indexes.

Edited by mosb3rgler
Link to comment
Share on other sites

actually, your explaination triggered the solution i nested 1 inside the other one, and used }} to close at the end, and got the results i was after very much thanks for the nudge bud. you guys are excellent teachers, you just know the right comments to make to make us take another look at it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.