<?php
header('Content-Type: text/html; charset=utf-8');
// str_lreplace 커스텀 함수의 (l)replace 소문자 '엘'은 Loop의 줄임말
function str_lreplace($find, $replace, $strings)
{
if ($strings && $find && $find!=$replace) {
if (stripos($replace, $find) !== false) {
$strings = str_ireplace($find, $replace, $strings);
}
else {
while(stripos($strings, $find) !== false) {
$strings = str_ireplace($find, $replace, $strings);
}
}
}
return $strings;
}
$test_str = '테스트 : testtesttestttesttestah!!testtesttesttesttesttesttesttttsseets 어지러워!';
$test_str_original = str_ireplace('testtest', 'test', $test_str);
$test_str_loop = str_lreplace('testtest', 'test', $test_str);
echo 'original text - '.$test_str;
echo '<br />';
echo 'str_ireplace - '.$test_str_original;
echo '<br />';
echo 'str_lreplace - '.$test_str_loop;
?>
[결과]
original text - 테스트 : testtesttestttesttestah!!testtesttesttesttesttesttesttttsseets 어지러워!
str_ireplace - 테스트 : testtestttestah!!testtesttesttesttttsseets 어지러워!
str_lreplace - 테스트 : testttestah!!testtttsseets 어지러워!
header('Content-Type: text/html; charset=utf-8');
// str_lreplace 커스텀 함수의 (l)replace 소문자 '엘'은 Loop의 줄임말
function str_lreplace($find, $replace, $strings)
{
if ($strings && $find && $find!=$replace) {
if (stripos($replace, $find) !== false) {
$strings = str_ireplace($find, $replace, $strings);
}
else {
while(stripos($strings, $find) !== false) {
$strings = str_ireplace($find, $replace, $strings);
}
}
}
return $strings;
}
$test_str = '테스트 : testtesttestttesttestah!!testtesttesttesttesttesttesttttsseets 어지러워!';
$test_str_original = str_ireplace('testtest', 'test', $test_str);
$test_str_loop = str_lreplace('testtest', 'test', $test_str);
echo 'original text - '.$test_str;
echo '<br />';
echo 'str_ireplace - '.$test_str_original;
echo '<br />';
echo 'str_lreplace - '.$test_str_loop;
?>
[결과]
original text - 테스트 : testtesttestttesttestah!!testtesttesttesttesttesttesttttsseets 어지러워!
str_ireplace - 테스트 : testtestttestah!!testtesttesttesttttsseets 어지러워!
str_lreplace - 테스트 : testttestah!!testtttsseets 어지러워!
게시글 목록
| 번호 | 제목 |
|---|---|
| 24318 | |
| 24317 | |
| 24315 | |
| 24309 | |
| 24294 | |
| 24293 | |
| 24277 | |
| 24262 | |
| 24260 | |
| 24253 | |
| 24251 | |
| 24236 | |
| 24233 | |
| 24228 | |
| 24226 | |
| 24221 | |
| 24214 | |
| 24203 | |
| 24201 | |
| 24199 | |
| 24196 | |
| 24195 | |
| 24194 | |
| 24192 | |
| 24191 | |
| 24187 | |
| 24185 | |
| 24183 | |
| 24172 | |
| 24168 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기