如何使用php删除破折号形式的任何字符串[关闭]

  $string="how-3981-make-scarecrow";
  $test = str_replace("-", " ", $string);
   echo $test;

Here i want to remove dash with space this is not working. can anyone help me.

This is possible in php we remove this..

Thanks

You are missing the dollarsign in your echo

$string="how-3981-make-scarecrow";
$test = str_replace("-", " ", $string);
echo $test;

By the way, there are a lots of SO links with similar questions:

It's working fine. Please refer to the code below.

echo $string = "how-3981-make-scarecrow";
$test = str_replace( "-", " ", $string );
echo $test;

Try this it is working fine

        $string="Hello-See-This-Is-Working";
        $result = str_replace("-", "", $string);
        echo $result;

        $string="Hello-See-This-Is-Working";
        $result = str_replace("-", " ", $string);
        echo $result;
        $string="Hello-See-This-Is-Working";
        $result = str_replace("-", "       ", $string);
        echo $result;

result

HelloSeeThisIsWorking
Hello See This Is Working
Hello See This Is Working