在字符串上的数字之间放置自定义字符

A piece of code would explain my problem

$string = '53 69 cm; 988 2460 g; wing 106 116 cm';
$patterns = array();
$patterns[0] = '/[0-9]+\s[0-9]+/';
$replacements = array();
$replacements[0] = '$0';
echo preg_replace($patterns, $replacements, $string,1);

I need to put a - between numbers, like:

$string = '53-69 cm; 988-2460 g; wing 106-116 cm';

How can I put the - on the replacement?

Thanks

Hope this gives you some help:

$string = '53 69 cm; 988 2460 g; wing 106 116 cm';
$pattern = '/(\d+)\s(\d+)/';
$replacement = '$1-$2';
echo preg_replace($pattern, $replacement, $string);

Output:

53-69 cm; 988-2460 g; wing 106-116 cm
$string = '53 69 cm; 988 2460 g; wing 106 116 cm';
$patterns[0] = '/([0-9]+)\s([0-9]+)/';
$replacements[0] = '$1-$2';

Also since you are doing single replacement you can just do:

$string = '53 69 cm; 988 2460 g; wing 106 116 cm';
$string = preg_replace('/([0-9]+)\s([0-9]+)/','$1-$2',$string);