I am trying to convert an underscore to dash in php.
hi i have a regular expression that converts white spaces to dash but how can i achieve underscore to dash?
$item = preg_replace('/\ +/', '-', $item);
You don't need a regular expression. Use str_replace
:
$item = str_replace('_', '-', $item);
preg_replace('/_/', '-', $item);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With