How to replace a hyphen with an empty space / space? Php

I don't know much about PHP, but I'm currently modifying an existing script. I want to know how I can replace - with white or blank space

For example, a variable contains “Love-you,” and I want to replace this hyphen between them with a space like “Love you”.

I will be grateful for your channel.

+3
source share
2 answers
$str = str_replace("-", " ", "Love-you");

now $str- "I love you";

http://php.net/manual/en/function.str-replace.php

+19
source

You can also use explodeandimplode

Here is an example

$string = "Love-You";
$arr = explode("-",$string);
$string = implode(" ",$arr);
0
source

Source: https://habr.com/ru/post/1752028/