문자열의 위치 문자 부터 변경 문자 반환 - mixed substr_replace ( mixed $string , mixed $replacement , mixed $start )
2014. 1. 13. 02:34
- <?php
- $invalue = "lunch time : twelve o'clock";
- $find = "twelve";
- echo substr_replace($invalue, "thirteen o'clock",
- strpos($invalue, $find))."<br>\n";
- // lunch time : thirteen o'clock
- echo substr_replace($invalue, "thirteen o'clock", 13, 6)."<br>\n";
- // lunch time : thirteen o'clock
- ?>
--------------------------------------------------------------------------------------------
mixed substr_replace ( mixed $string , mixed $replacement , mixed $start [, mixed $length ] )
5.9. 라인
$string문자열에서 $start 위치의 문자부터 끝까지의 문자열을 $replacement문자열로 반환합니다.
또한 $length가 정해주면
$string문자열에서 $start 위치의 문자부터 $length길이 까지의 문자열을
$replacement문자열로 반환합니다.
※ strpos()함수를 이용하면 편하게 반환할수 있습니다.