I want to convert multiple spaces to a hyphen.

For example, if there are 3 or more consecutive spaces between words in a string, then I want to convert them to a hyphen. 

original string :

```
 $x="Hello    world! I am new        here.

```

string after execution: 

```
 Hello-world! I am new-here 

```

I have tried the following, but it does not seem to work properly. 

```
 <?php
 $str="Hello    world! I am new     here";
 echo preg_replace("/.*\s{3}/","-",$str); 

```