paulmagm Posted October 5 Share Posted October 5 (edited) Hey, I have a table with match results. <?php foreach ($matches as $match) { ?> $match["matchResults"][0]["pointsTeam1"] $match["matchResults"][1]["pointsTeam1"] n the first line i have the score [1] (game finished) on all other lines (td) i have the score [0] halftime score. How can i change it that in every line i have [1] with finished score? Maybe you can help me. Thanks! <?php foreach ($matches as $match) { ?> <tr><td></td> <td><img src="<?php echo $match["team1"]["teamIconUrl"]; ?>" height="25"></td> <td class="result"> <?php echo $match["matchResults"][1]["pointsTeam1"]; ?> : <?php echo $match["matchResults"][1]["pointsTeam2"]; ?> </td> <td><img src="<?php echo $match["team2"]["teamIconUrl"]; ?>" height="25"></td> </tr> <?php } ?> Thanks Edited October 5 by paulmagm Quote Link to comment https://forums.phpfreaks.com/topic/324625-problem-with-api-call-in-a-table/ Share on other sites More sharing options...
requinix Posted October 6 Share Posted October 6 Seems you've already done that. So what's the problem? Quote Link to comment https://forums.phpfreaks.com/topic/324625-problem-with-api-call-in-a-table/#findComment-1636893 Share on other sites More sharing options...
paulmagm Posted October 6 Author Share Posted October 6 (edited) I have 5 Games in that table. With the code in my first post. It repeats automatic. the table lines. Team1 Team2 2:1 (all fine) Team1 Team2 1:1 Team1 Team2 0:0 Team1 Team2 0:0 Team1 Team2 0:0 But on the last 4 games i have the [0] haltime result not the [1] finished result like in the first game. And i don't know why. Thanks for your time! Edit: Hm now it works.. maybe it was just in the cache? haha.. Edited October 6 by paulmagm Quote Link to comment https://forums.phpfreaks.com/topic/324625-problem-with-api-call-in-a-table/#findComment-1636915 Share on other sites More sharing options...
paulmagm Posted October 6 Author Share Posted October 6 (edited) I have two other questions (and last questions).A. How can i echo a simple Array without the that $match and automatic repeat? Like <?php echo $match["group"]["groupName"]; ?> B. How can i format that date which this API echo me like. <?php echo $match["matchDateTime"]; ?> I get back this 2024-10-06T09:19:53.660Z I tried it often.. to bring it in Sa., 6.10. - 15:30. But it doesn't work. I have often two dates then in my echo and no good format. Thanks! Edited October 6 by paulmagm Quote Link to comment https://forums.phpfreaks.com/topic/324625-problem-with-api-call-in-a-table/#findComment-1636917 Share on other sites More sharing options...
Barand Posted October 6 Share Posted October 6 A. echo '<pre>' . print_r($match, true) . '</pre>'; B. $dt = new DateTime('2024-10-06T09:19:53.660Z'); echo $dt->format('D, d.m - h:i'); // Sun, 06.10 - 09:19 Quote Link to comment https://forums.phpfreaks.com/topic/324625-problem-with-api-call-in-a-table/#findComment-1636923 Share on other sites More sharing options...
paulmagm Posted October 6 Author Share Posted October 6 Thanks for your help! But.. A. I have to include this "["group"]["groupName"]". $match has no value. B. I have to include $match["matchDateTime"] instead of your timestamp. Quote Link to comment https://forums.phpfreaks.com/topic/324625-problem-with-api-call-in-a-table/#findComment-1636926 Share on other sites More sharing options...
Barand Posted October 9 Share Posted October 9 On 10/6/2024 at 12:05 PM, paulmagm said: A. I have to include this "["group"]["groupName"]". $match has no value. I cannot comment as I have absolutely no idea what your data looks like On 10/6/2024 at 12:05 PM, paulmagm said: B. I have to include $match["matchDateTime"] instead of your timestamp. Then do that... $dt = new DateTime($match['matchDateTime']); Quote Link to comment https://forums.phpfreaks.com/topic/324625-problem-with-api-call-in-a-table/#findComment-1637205 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.