mosb3rgler Posted June 11, 2019 Share Posted June 11, 2019 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 Quote Link to comment Share on other sites More sharing options...
requinix Posted June 11, 2019 Share Posted June 11, 2019 That Pastebin is private. Quote Link to comment Share on other sites More sharing options...
mosb3rgler Posted June 11, 2019 Author Share Posted June 11, 2019 ok, so i noticed i change the index after games to 1 or 2 etc, and then otherwise it shows everything i need it too.. is there an approach that can check each of the index and posting similar to if it was all with in the same array. Quote Link to comment Share on other sites More sharing options...
mosb3rgler Posted June 11, 2019 Author Share Posted June 11, 2019 1 minute ago, requinix said: That Pastebin is private. sorry about that i edited it to unlisted you can see it now. Quote Link to comment Share on other sites More sharing options...
requinix Posted June 11, 2019 Share Posted June 11, 2019 So you already have a foreach on the dates, suggesting you understand the foreach and the dates. Sounds like what you want is a secondary foreach on the $arr[games]... Quote Link to comment Share on other sites More sharing options...
mosb3rgler Posted June 11, 2019 Author Share Posted June 11, 2019 (edited) 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 June 11, 2019 by mosb3rgler Quote Link to comment Share on other sites More sharing options...
mosb3rgler Posted June 11, 2019 Author Share Posted June 11, 2019 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.