- var_dump: documentation ( source)
- preg_replace_callback: documentation ( source)
- number_format: documentation ( source)
<?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);