Hello! Tell me, please, how in the line to replace the forward slash with the underscore '_'. Below is the code, but for some reason it does not work:

$vv = 'SAMSUNG/1'; $model = str_replace('\/', '_', $vv); 

    1 answer 1

    Your code does not work, because the preg_replace function is used for regular expressions. In the case of str_replace , the correct code will look like this:

     $vv = 'SAMSUNG/1'; $model = str_replace('/', '_', $vv); 

    If the condition is to use regular expressions, then:

     $vv = 'SAMSUNG/1'; $model = preg_replace('/\//', '_', $vv);