3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $price = 10; $currencyCode = 'EUR'; switch ($currencyCode) { case 'EUR': $price_tab = explode('.',$price); if (sizeof($price_tab) == 2) { if ($price_tab[1] == '00') { $price = $price_tab[0].' €'; } else { $price = $price_tab[0].','.$price_tab[1].' €'; } } elseif (is_numeric($price)) { $price = $price.'€'; } break; case 'CHF': $price_tab = explode('.', $price); if (sizeof($price_tab) == 2) { if ($price_tab[1] == '00') { $price = 'CHF '.$price_tab[0].'.-'; } else { $price = 'CHF '.$price; } } elseif (is_numeric($price)) { $price = 'CHF '.$price.'.-'; } break; default: return $price; break; } echo $price; ?>
Output for 4.3.0 - 7.1.0
10€