반응형
단어 사이의 공백을 하이픈으로 바꾸는 정규식 함수입니다.
<?php
function create_slug($string){
$slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string);
return $slug;
}
echo create_slug('does this thing work or not');
//returns 'does-this-thing-work-or-not'
?>
'css' 카테고리의 다른 글
완벽한 CSS 사이다 - 슬라이딩 도어 버튼 (0) | 2021.10.09 |
---|---|
범용 IE 6 스타일시트 제공 (0) | 2021.10.09 |
배열의 각 항목에 대해 함수 수행 (0) | 2021.10.09 |
아름다운 HTML 코드의 모습 (0) | 2021.10.09 |
더 북: 워드프레스 파고들기 (0) | 2021.10.09 |
댓글