3v4l.org

run code in 300+ PHP versions simultaneously
<?php $Ucountries = ["Uganda", "Ukraine", "United Arab Emirates (UAE)", "United Kingdom (UK)", "United States of America (USA)", "Uruguay", "Uzbekistan"]; $Mcountries = ["Macedonia (FYROM)", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Myanmar (Burma)"]; $str = "countries_mexico_mexico_city"; //$str = "countries_united_states_ohio"; $str = str_replace("countries_", "", $str); // Copy array needed to $CountryList $CountryList = ${strtoupper(substr($str,0,1)). "countries"}; $countryarr = array(); $arr = explode("_", $str); Foreach($arr as $val){ Foreach($CountryList as $item){ If(stripos($item, $val) !== false){ If(!in_array($val, $countryarr)){ $countryarr[] = $val; } } } } $country = implode(" ", $countryarr); $state_city = preg_replace("/" . implode("_",$countryarr) . "/", "", $str,1); $state_city = trim(str_replace("_", " ", $state_city)); Echo $country . "\n" . $state_city;
Output for git.master, git.master_jit, rfc.property-hooks
mexico mexico city

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
70.1 ms | 405 KiB | 5 Q