$s = "This is a 1,5k String and 1k ";
echo replaceThousands($s);
function replaceThousands($s)
{
$regex = "/(\d?,?\d)k/";
$m = preg_match_all($regex, $s, $matches);
foreach($matches[1] as $i => $match)
{
$new = str_replace(",", ".", $match);
$new = 1000*$new;
$s = preg_replace("/" .$match."k/", $new, $s);
}
return $s;
}