cowboysdude Posted January 5, 2016 Share Posted January 5, 2016 (edited) Here are my arrays. I'm using a search and replace with them... $find = array( "TBD", "ARI", "ATL", 'BAL', 'BUF', 'CAR', 'CHI', 'CIN', 'CLE', 'DAL', 'DEN', 'DET', 'GB', 'HOU', 'IND', 'JAC', 'KC', 'MIA', 'MIN', 'NE', 'NO', 'NYJ', 'NYG', 'OAK', 'PHI', 'PIT', 'STL', 'SD', 'SF', 'SEA', 'TB', 'TEN', 'WAS', 'RIC', 'IRV' ); $replace = array( "<img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/tbd.png'> TBD</a>", "<a href='http://www.azcardinals.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/cards.png'> Cardinals</a>", "<a href='http://www.atlantafalcons.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/falcons.png' > Falcons</a>", "<a href='http://www.baltimoreravens.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/ravens.png' > Ravens</a>", "<a href='http://www.buffalobills.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/bills.png' > Bills</a>", "<a href='http://www.panthers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/panthers.png' > Panthers</a>", "<a href='http://www.chicagobears.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/bears.png' > Bears</a>", "<a href='http://www.bengals.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/bengals.png' > Bengals</a>", "<a href='http://www.clevelandbrowns.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/browns.png' > Browns</a>", "<a href='http://www.dallascowboys.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/cowboys.png' > Cowboys</a>", "<a href='http://www.denverbroncos.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/broncos.png' > Broncos</a>", "<a href='http://www.detroitlions.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/lions.png' > Lions</a>", "<a href='http://www.packers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/packers.png' > Packers</a>", "<a href='http://www.houstontexans.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/texans.png' > Texans</a>", "<a href='http://www.colts.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/colts.png' > Colts</a>", "<a href='http://www.jaguars.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/jags.png' > Jaguars</a>", "<a href='http://www.chiefs.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/chiefs.png' > Chiefs</a>", "<a href='http://www.miamidolphins.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/dolphins.png' > Dolphins</a>", "<a href='http://www.vikings.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/viks.png' > Vikings</a>", "<a href='http://www.patriots.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/pats.png' > Patriots</a>", "<a href='http://www.neworleanssaints.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/saints.png' > Saints</a>", "<a href='http://www.newyorkjets.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/jets.png' > Jets</a>", "<a href='http://www.giants.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/giants.png' > Giants</a>", "<a href='http://www.raiders.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/raiders.png' > Raiders</a>", "<a href='http://www.philadelphiaeagles.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/eagles.png' > Eagles</a>", "<a href='http://www.steelers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/steelers.png' > Steelers</a>", "<a href='http://www.stlouisrams.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/rams.png' > Rams</a>", "<a href='http://www.chargers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/chargers.png' > Chargers</a>", "<a href='http://www.49ers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/49ers.png' > 49ers</a>", "<a href='http://www.seahawks.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/seahawks.png' > Seahawks</a>", "<a href='http://www.buccaneers.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/bucs.png' > Buccaneers</a>", "<a href='http://www.titansonline.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/titans.png' > Titans</a>", "<a href='http://www.redskins.com/' target='_blank'><img src='". JUri::base() ."/modules/mod_scores/assets/img/teams/redskins.png' > Redskins</a>", "Team Rice", "Team Irving" ); The question I have is that there is a TBD which is close to TB.. when the output is TBD it's using both outputs like this: TBD image TB image BuccanersD How can I get around the fact that they are so close? Thank you! Edited January 5, 2016 by cowboysdude Quote Link to comment Share on other sites More sharing options...
requinix Posted January 5, 2016 Share Posted January 5, 2016 How are you doing the replace? What's the rest of the code? Quote Link to comment Share on other sites More sharing options...
cowboysdude Posted January 5, 2016 Author Share Posted January 5, 2016 $visitingTeam = str_replace($find, $replace, $game['v']); It was working great until the TBD entered ... it works great all season but now that there is a TBD ... it's throwing things off. Quote Link to comment Share on other sites More sharing options...
requinix Posted January 5, 2016 Share Posted January 5, 2016 str_replace() works by doing each pair of replacements in turn. First, then second, then third, and so on. Since "TBD" will replace to something containing "TB", the "TB" replacement will also work on that. You have to make sure that the array is ordered so that doesn't happen. Moving TBD to the end should do 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.