php 공백을 dash 로 바꾸기
str_replace(' ', '-', $string);
php 공간을 대시로 바꾸기
<?php
$string = "hello php";
$replace = str_replace(" ", "_", $string);
echo $replace; // hello_php
?>
php 는 모든 공백을 대시로 바꿉니다
// Clean up multiple dashes or whitespaces
$string = preg_replace("/[\s-]+/", " ", $string);
// Convert whitespaces and underscore to dash
$string = preg_replace("/[\s_]/", "-", $string);