cowboysdude Posted January 3, 2015 Share Posted January 3, 2015 (edited) With a TON of help from you guys already it's working but I do have one thing that I just need to figure out to clean it all up... echo $games['htn']," ",$games['hs']," VS ",$games['vtn']," ",$games['vs']," on ",$games['d']," at ",$games['t']; This is returning what I need perfectly except if an object is empty it's also showing that.. for example... Pittsburgh Steelers 0 VS Baltimore Ravens 0 on Sat at 8:15 --- is what I want to show... shows up great then the next line will show an empty set because the games are not known until other games are played so I also get this: 0 VS 0 on Jan 18 at 3:05 and Seattle Seahawks 0 VS 0 on Jan 10 at 8:15 What can I do to make this not show up? $xml = simplexml_load_string($data); // print_r($xml); foreach($xml->gms->g as $games) { echo "<div class='button blue'>"; echo $games['htn']," ",$games['hs']," VS ",$games['vtn']," ",$games['vs']," on ",$games['d']," at ",$games['t']; echo "</div>"; } This is what I have and it's working with a lot of help from you guys... I just need to clean it up so I can show only games that have two teams listed.. Thanks again everyone!! Edited January 3, 2015 by cowboysdude Quote Link to comment Share on other sites More sharing options...
requinix Posted January 3, 2015 Share Posted January 3, 2015 You can make it not show up by checking to see if the line is "empty" and not showing the data if it is. Quote Link to comment Share on other sites More sharing options...
Solution Psycho Posted January 3, 2015 Solution Share Posted January 3, 2015 foreach($xml->gms->g as $games) { //Skip if either team name is empty if(empty($games['htn']) || empty($games['vtn'])) { continue; } //If both scores are 0, don't show them (game hasn't been played) if($games['hs']==0 && $games['hs']==0) { $games['hs'] = ''; $games['vs'] = ''; } echo "<div class='button blue'>"; echo "{$games['htn']} {$games['hs']} VS {$games['vtn']} {$games['vs']} on {$games['d']} at {$games['t']}"; echo "</div>"; } 1 Quote Link to comment Share on other sites More sharing options...
cowboysdude Posted January 3, 2015 Author Share Posted January 3, 2015 Went with this one and it worked... Thank you!!! if(!empty($games['vtn'])) BUT I think I like your's better... I'm going to have to try it!! Thank you very much!! 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.