php 문자열 찾기 함수
페이지 정보
작성자 서방님 댓글 0건 조회 94회 작성일 13-04-02 11:08본문
eregi()
eregi('찾을 문자열', '원본문자열'); //대소문자 구분 안함
문자열이 포함되어있는지 검사.
리턴은 1,0
ereg()
ereg('찾을 문자열', '원본문자열'); //대소문자 구분 함
문자열이 포함되어있는지 검사
리턴은 1,0;
- strpos() - 문자열이 처음 나타나는 위치를 찾습니다
- strripos() - 문자열에서 대소문자 구분 없이 문자열의 마지막 위치를 찾습니다
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme); //$pos == 0
$findme = 'a';
$pos = strpos($mystring, $findme); //$pos == 0
//세번째 파라미터는 오프셋 디폴트 0,
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0
자르는 함수들
<?php
$email = 'name@example.com';
$domain = strstr($email, '@');
echo $domain; // @example.com 출력
$user = strstr($email, '@', true); // As of PHP 5.3.0
echo $user; // name 출력
?>
댓글목록
등록된 댓글이 없습니다.