PHP 数字、小数点、マイナスのみ正規表現

PHP 数字、小数点、マイナスのみ正規表現
$dat = preg_replace(‘/[^0-9.-]/’, ”, $dat)
0-9の数字,「.」、「-」以外はスペースにという表示形式

「,」だけとりたいのなら
$dat = str_replace(”,”, ”, $dat)

整数のみなら
preg_replace(‘/[^0-9-]/’, ”,number_format($dat,0))

小数点なら(3ケタ)
preg_replace(‘/[^0-9.-]/’, ”,number_format($dat,3))

カテゴリー php