Replace character of a string

-1

I'm trying to remove all hyphens from my string when it is returned.

$hash = $result[2];

Return me:

0DE8072B-C3BE-4A94-B412-3679F7C79913

I want to define a variable that removes all hyphens from the variable $hash

    
asked by anonymous 04.06.2018 / 22:53

2 answers

2

You can use str_replace in this case, replacing the hyphen with an empty string, like this:

$hash = str_replace("-", "", $result[2]);
    
04.06.2018 / 23:02
0

Use str_replace ()

$new_var = str_replace("-", "alguma coisa", $hash);
    
04.06.2018 / 22:58