PHP
[PHP] 문자열의 모든 공백 제거 preg_replace()
chsr
2021. 9. 1. 10:39
728x90
반응형
■ PHP 문자열의 모든 공백 제거 preg_replace()
■ 문법
preg_replace(
string|array $pattern,
string|array $replacement,
string|array $subject,
int $limit = -1,
int &$count = null
): string|array|null
■ 모든 공백 제거 시 사용법
$tmp_string = "
안녕하세 요
잘부탁드립니 다
";
echo preg_replace('/\s+/', '', $tmp_string); // 안녕하세요잘부탁드립니다
728x90
반응형