{"id":47651,"date":"2020-01-11T03:01:45","date_gmt":"2020-01-10T17:01:45","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=47651"},"modified":"2020-01-10T13:35:52","modified_gmt":"2020-01-10T03:35:52","slug":"php-worldbank-growth-of-merchandise-trade-emoji-flags-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-worldbank-growth-of-merchandise-trade-emoji-flags-tutorial\/","title":{"rendered":"PHP Worldbank Growth of Merchandise Trade Emoji Flags Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade_2006_2016.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"PHP Worldbank Growth of Merchandise Trade Emoji Flags Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade_2006_2016.jpg\" title=\"PHP Worldbank Growth of Merchandise Trade Emoji Flags Tutorial\"  style=\"float:left;\"  \/><\/a><p class=\"wp-caption-text\">PHP Worldbank Growth of Merchandise Trade Emoji Flags Tutorial<\/p><\/div>\n<p>With Internationalization thoughts fresh in the mind, we decided to revisit <a title='PHP Worldbank Growth of Merchandise Trade Tutorial' href='#phpwgmtt'>PHP Worldbank Growth of Merchandise Trade Tutorial<\/a>&#8216;s Country by Country &#8220;Growth of Merchandise Trade&#8221; Bubble Chart to see what we now know more about to improve this web application.<\/p>\n<p>And so we wondered whether we could enhance with Emoji Flags.  Sounds reasonable, but when we&#8217;ve done this in the recent past (eg. <a target=_blank title='Window LocalStorage Client Versus Server Map Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/window-localstorage-client-versus-server-map-tutorial\/'>Window LocalStorage Client Versus Server Map Tutorial<\/a>) it&#8217;s been with Javascript clientside logic, not PHP serverside code, as is the go with our <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/index' title='Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.'>Google Chart<\/a> <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/gallery\/bubblechart' title='Bubble Chart'>Bubble Chart<\/a> interfacing.  Well, here&#8217;s our approach (making global $flagentity variable filled in with Emoji Flag content as found) here &#8230;<\/p>\n<p>&lt;?php<br \/>\n<code><br \/>\n$flagentity=\"\";  \/\/ global here and two below<br \/>\n$lri=[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\"];<br \/>\n$dri=[\"U+1F1E6\",\"U+1F1E7\",\"U+1F1E8\",\"U+1F1E9\",\"U+1F1EA\",\"U+1F1EB\",\"U+1F1EC\",\"U+1F1ED\",\"U+1F1EE\",\"U+1F1EF\",\"U+1F1F0\",\"U+1F1F1\",\"U+1F1F2\",\"U+1F1F3\",\"U+1F1F4\",\"U+1F1F5\",\"U+1F1F6\",\"U+1F1F7\",\"U+1F1F8\",\"U+1F1F9\",\"U+1F1FA\",\"U+1F1FB\",\"U+1F1FC\",\"U+1F1FD\",\"U+1F1FE\",\"U+1F1FF\"];<br \/>\n$iso_country_codes=['AF','Afghanistan',<br \/>\n'AX','Aland Islands',<br \/>\n'AL','Albania',<br \/>\n'DZ','Algeria',<br \/>\n'AS','American Samoa',<br \/>\n'AD','Andorra', ... ];  \/\/ global ... not all shown<br \/>\n<br \/>\nfunction uvaltosfcp($string) { \/\/ thanks to <a target=_blank title='https:\/\/stackoverflow.com\/questions\/1805802\/php-convert-unicode-codepoint-to-utf-8' href='https:\/\/stackoverflow.com\/questions\/1805802\/php-convert-unicode-codepoint-to-utf-8'>https:\/\/stackoverflow.com\/questions\/1805802\/php-convert-unicode-codepoint-to-utf-8<\/a><br \/>\n  return <a target=_blank title='PHP html-entity-decode function information' href='https:\/\/www.php.net\/manual\/en\/function.html-entity-decode.php'>html_entity_decode<\/a>(preg_replace(\"\/U\\+([0-9A-F]{5})\/\", \"&#x\\\\1;\", $string), ENT_NOQUOTES, 'UTF-8');<br \/>\n}<br \/>\n<br \/>\nfunction flagflag($inctryname) {<br \/>\n  global $flagentity, $iso_country_codes, $lri, $dri;<br \/>\n  $uretv=\"\";<br \/>\n  $flagentity=\"\";<br \/>\n  if ($inctryname != \"\") {<br \/>\n  $matchfound=false;<br \/>\n  for ($im=1; $im&lt;sizeof($iso_country_codes); $im+=2) {<br \/>\n    if (strpos(strtolower($iso_country_codes[$im]), strtolower($inctryname)) !== false) {<br \/>\n      for ($jm=0; $jm&lt;sizeof($lri); $jm++) {<br \/>\n       if (strtoupper(substr($iso_country_codes[-1 + $im],0,1)) == $lri[$jm]) {<br \/>\n         $uretv.=$dri[$jm]; \/\/uvaltosfcp($dri[$jm]);<br \/>\n         $matchfound=true;<br \/>\n       }<br \/>\n      }<br \/>\n      for ($jm=0; $jm&lt;sizeof($lri); $jm++) {<br \/>\n       if (strtoupper(substr($iso_country_codes[-1 + $im],1,1)) == $lri[$jm]) {<br \/>\n         $uretv.=$dri[$jm]; \/\/uvaltosfcp($dri[$jm]);<br \/>\n       }<br \/>\n      }<br \/>\n      $flagentity=uvaltosfcp($uretv); \/\/$uretv;<br \/>\n      return $inctryname;<br \/>\n    }<br \/>\n  }<br \/>\n  if ($uretv == \"\" && !$matchfound) {<br \/>\n  for ($im=1; $im&lt;sizeof($iso_country_codes); $im+=2) {<br \/>\n    if (strpos(explode(\",\",strtolower($iso_country_codes[$im]))[0], explode(\",\",strtolower($inctryname))[0]) !== false) {<br \/>\n      for ($jm=0; $jm&lt;sizeof($lri); $jm++) {<br \/>\n       if (strtoupper(substr($iso_country_codes[-1 + $im],0,1)) == $lri[$jm]) {<br \/>\n         $uretv.=$dri[$jm]; \/\/uvaltosfcp($dri[$jm]);<br \/>\n         $matchfound=true;<br \/>\n       }<br \/>\n      }<br \/>\n      for ($jm=0; $jm&lt;sizeof($lri); $jm++) {<br \/>\n       if (strtoupper(substr($iso_country_codes[-1 + $im],1,1)) == $lri[$jm]) {<br \/>\n         $uretv.=$dri[$jm]; \/\/uvaltosfcp($dri[$jm]);<br \/>\n       }<br \/>\n      }<br \/>\n      $flagentity=uvaltosfcp($uretv); \/\/$uretv;<br \/>\n      return $inctryname;<br \/>\n    }<br \/>\n  }<br \/>\n  }<br \/>\n  }<br \/>\n  return $inctryname;<br \/>\n}<br \/>\n<\/code><br \/>\n?&gt;<\/p>\n<p>Another &#8220;peer integration&#8221; issue today too.  The resource we&#8217;d like to thank regarding today&#8217;s work, that being <a target=_blank title='Growth of Merchandise Trade 2003-2013' href='http:\/\/wdi.worldbank.org\/table\/6.1'>Growth of Merchandise Trade<\/a> has updated its data set for the year range 2006-2016 and we&#8217;d like to maintain this, and the previous 2003-2013 data set, for comparison purposes.  The Bubble Chart report is the important thing though, and so a select (dropdown) element, probably &#8220;below the fold&#8221; for you, facilitates this expansion of functionality.<\/p>\n<p>To try the <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade_2006_2016.php--GETME\" title=\"growth_of_merchandise_trade_2006_2016.php\">&#8220;how we got there&#8221;<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade_2006_2016.php--GETME\" title=\"growth_of_merchandise_trade_2006_2016.php\">growth_of_merchandise_trade_2006_2016.php<\/a> you can click\/touch this <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade_2006_2016.php\" title=\"Click picture\">live run<\/a> link.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/php-worldbank-growth-of-merchandise-trade-emoji-flags-tutorial\/'>PHP Worldbank Growth of Merchandise Trade Emoji Flags Tutorial<\/a>.<\/p-->\n<hr>\n<p id='phpwgmtt'>Previous relevant <a target=_blank title='PHP Worldbank Growth of Merchandise Trade Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/php-worldbank-growth-of-merchandise-trade-tutorial\/'>PHP Worldbank Growth of Merchandise Trade Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"PHP Worldbank Growth of Merchandise Trade Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade.jpg\" title=\"PHP Worldbank Growth of Merchandise Trade Tutorial\"  style=\"float:left;\"  \/><\/a><p class=\"wp-caption-text\">PHP Worldbank Growth of Merchandise Trade Tutorial<\/p><\/div>\n<p>We&#8217;ve said it before, and (no doubt) we&#8217;ll say it again &#8230; there are great public data sources out there for you to explore.<\/p>\n<p>As far as international data goes the <a target=_blank title='Worldbank data source' href='http:\/\/wdi.worldbank.org\/'>Worldbank<\/a> series of statistics is great, so, thanks.<\/p>\n<p>Today we combine the Worldbank data for <a target=_blank title='Growth of Merchandise Trade 2003-2013' href='http:\/\/wdi.worldbank.org\/table\/6.1'>Growth of Merchandise Trade 2003-2013<\/a> with the wonderful <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/index' title='Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.'>Google Chart<\/a> Bubble Chart to create (52 = (first letters of country name) 26 x 2 (concepts: Exports and Imports)) reporting charts of interest, we hope.  Again, as with any reporting subject, it is a personal thing, whether the subject matter of a report is of interest, but you could say that about so many things in life.<\/p>\n<p>So, we offer some PHP source code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade.php_GETME\" title='growth_of_merchandise_trade.php'>growth_of_merchandise_trade.php<\/a> and a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade.php\" title=\"Click picture\">live run<\/a> link as well, the full loading of which requires patience.<\/p>\n<p><b><i>Stop Press<\/i><\/b><\/p>\n<p>Tomorrow we go over what was needed to change PHP code above to be more mobile friendly &#8230;<\/p>\n<blockquote>\n<ul>\n<li><a href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade.php-GETME\" title=\"growth_of_merchandise_trade.php\" target=\"_blank\">growth_of_merchandise_trade.php<\/a> <a href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade.php-GETME\" title=\"growth_of_merchandise_trade.php\" target=\"_blank\">changes<\/a> (to cater for select event (mobile touch) functionality) and <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/BubbleChart\/growth_of_merchandise_trade.php\" title='growth_of_merchandise_trade.php'>live run<\/a> link for yesterday&#8217;s web application<\/li>\n<\/ul>\n<\/blockquote>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d19609' onclick='var dv=document.getElementById(\"d19609\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/php\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d19609' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d47651' onclick='var dv=document.getElementById(\"d47651\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/emoji\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d47651' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>With Internationalization thoughts fresh in the mind, we decided to revisit PHP Worldbank Growth of Merchandise Trade Tutorial&#8216;s Country by Country &#8220;Growth of Merchandise Trade&#8221; Bubble Chart to see what we now know more about to improve this web application. &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-worldbank-growth-of-merchandise-trade-emoji-flags-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[166,385,2242,452,518,576,587,932,970,997,1319,1460],"class_list":["post-47651","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-bubble-chart","tag-emoji","tag-flag","tag-form","tag-google-chart","tag-html","tag-iframe","tag-php","tag-post","tag-programming","tag-tutorial","tag-worldbank"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/47651"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=47651"}],"version-history":[{"count":7,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/47651\/revisions"}],"predecessor-version":[{"id":47658,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/47651\/revisions\/47658"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=47651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=47651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=47651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}