{ if ($change > 0.0) { return "<span style='color:green'>↑ {$change} </span>"; } else { return "<span style='color:red'>↓ {$change} </span>"; } } $queryURL = "http://finance.yahoo.com/webservice/v1/symbols/BKCC,BCO,WTR,VR,NRZ,WBS,EMLP,CTB,SIMO,HPT,AFSI,LM,GT,CPK,SMP,OMI,OHI,MATW,IQNT,PRI,AIT,POR,GLT,HRS,KBWP,FRAF,FDP,CLH,ALE,UVV,AEE,PSCT,CCE,CACI,RMD,TSO,TAP,SCG,VAW,EMN,SSS,IYT,RCD,DGX,RMR/quote?format=json&view=detail"; $session = curl_init($queryURL); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $json = curl_exec($session); $phpObj = json_decode($json); for ($i = 0; $i < 35; $i++) { $stock = $phpObj->{'list'}->{'resources'}[$i]->{'resource'}->{'fields'}; echo "<span style='color:white'>" . $stock->{'symbol'} . "</span>"; echo setStockChange($stock->{'change'}); } curl_close($session); ?> </h3> </div> <hr> <p> <ul class="list-group"> <?php $url = "https://feeds.finance.yahoo.com/rss/2.0/headline?s=aapl,bac,cvs,cat,rmax,wmt,t,cmc,so,mmp®ion=US&lang=en-US"; $rssOutput = getResults($url); $results = $rssOutput->channel; $count = 0; while ($count < count($results->item)) {
function setStockChange($change) { if ($change > 0) { return "<p style='color:green'>↑ {$change}</p>"; } else { return "<p style='color:red'>↓ {$change}</p>"; } } $api_url = "http://finance.yahoo.com/webservice/v1/symbols/BKCC,BCO,WTR,VR,NRZ,WBS,EMLP,CTB,SIMO,HPT/quote?format=json&view=detail"; $session = curl_init($api_url); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $json = curl_exec($session); $phpObj = json_decode($json); for ($i = 0; $i < 10; $i++) { $stock = $phpObj->{'list'}->{'resources'}[$i]->{'resource'}->{'fields'}; echo "<tr class='holdings_row'><td class='holdings_data'><p>" . $stock->{'symbol'} . "</p></td><td class='holdings_data'><p>" . $stock->{'name'} . "</p></td><td class='holdings_data'><p>\$" . $stock->{'price'} . "</p></td><td class='holdings_data'>" . setStockChange($stock->{'change'}) . '</td></tr>'; } curl_close($session); ?> </table> </div> <div class="clearfix"></div> </div> </div> <footer> <div class="container"> <div class="row"> <div class="col-lg-12 text-center"> <p>Copyright © Radford SMIPO 2016</p>