3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $input = array("3.45Lt", "1.00€"); function kazkas($match){ if($match[3]==="LTL"){ $match[3] = "EUR"; } elseif($match[3]==="Lt" | $match[3]==="LT" | $match[3]==="lT" |$match[3] === "lt"){ $match[3] = "€"; }else{ $match[3]=$match[3]; } $changeratio = 3.4488; return number_format($match[1]/$changeratio,2).$match[2].$match[3]; //3.4492 } $result = preg_replace_callback('/(\d+[,.]?\d?)(\s?)(L+T+L?)/iD','kazkas',$input); var_dump($result);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(2) { [0]=> string(10) "3.13.05€" [1]=> string(7) "1.00€" }