문자열 찾기 처음 위치 반환 - mixed strpos ( string $haystack ), int stripos ( string $haystack )
2014. 1. 11. 17:04
- <?php
- $invalue = "abcd efg hijk abcd efg hijk";
- // 대문자
- $upper = "eFg";
- // 소문자
- $lower = "efg";
- $i = 0;
- while($i < 2){
- switch($i){
- case 1: $find = $upper;
- echo "대문자 찾기<br>\n";
- break;
- default: $find = $lower;
- echo "소문자 찾기<br>\n";
- break;
- }
- echo "strpos :".strpos($invalue, $find)."<br>\n";
- echo "stripos :".stripos($invalue, $find)."<br>\n";
- echo "<br>\n";
- $i++;
- }
- /*
- 소문자 찾기
- strpos :5
- stripos :5
- 대문자 찾기
- strpos :
- stripos :5
- */
- ?>
--------------------------------------------------------------------------------------------
mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )
17. 라인
$haystack문자열에서 $needle문자열을 찾으면 찾은 처음 위치 값을 반환합니다.(숫자)
찾지 못하면 FALSE 값을 반환합니다.(NULL값 반환)
int stripos ( string $haystack , string $needle [, int $offset = 0 ] )
18. 라인
strpos()함수와 같지만 대소문자 구분 안합니다.