3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $price = '10.156'; $price = str_replace(',', '', $price); $price = str_replace('.', ',', $price); // print ($price); print (strpos($price, ",")); if (strpos($price, ',') !== false) { $nbchardecim = strlen(substr($price, strpos($price, ",") + 1)) ; if ($nbchardecim > 2) { $price = substr($price, 0,strlen($price)- $nbchardecim+2); } } print ($price);
based on WaqoH
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.6
210,15