anilm Posted November 21, 2013 Share Posted November 21, 2013 Hi I need to replace country abbreviations with the appropriate country flag. The php line on the website is a call from an ebay api: print "<h5>".$item["COUNTRY"]."</h5>"; so, if the country is Spain, the result ES is printed I have an image folder with all the countries flags, and this particular case, it is called ES.png. There is also a mySql database in the format: ID, name,abbr (in this case: 1,Spain,ES) Is there an easy way to do this dynamically? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/284140-replace-text-with-flag/ Share on other sites More sharing options...
Solution Ch0cu3r Posted November 21, 2013 Solution Share Posted November 21, 2013 (edited) Output $item["COUNTRY] into the image path echo '<img src="path/to/country/images/'.$item['COUNTRY'].'.png" />'; You can do he same thing for when you get the country code out of the database too. Edited November 21, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/284140-replace-text-with-flag/#findComment-1459397 Share on other sites More sharing options...
anilm Posted November 21, 2013 Author Share Posted November 21, 2013 Brilliant. Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/284140-replace-text-with-flag/#findComment-1459399 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.