subpattern name
$str = "2010-10-29";
preg_match("/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)/", $str, $matches);
//preg_match("/(?<year>\d+)-(?<month>\d+)-(?<day>\d+)/", $str, $matches);
echo $matches['year'];
echo $matches['month'];
echo $matches['day'];
일치하는곳의 이름을 지정할 수 있다<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 18:00:23 Regular Expression (정규표현식)에서 이동 됨]</div>
preg_match("/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)/", $str, $matches);
//preg_match("/(?<year>\d+)-(?<month>\d+)-(?<day>\d+)/", $str, $matches);
echo $matches['year'];
echo $matches['month'];
echo $matches['day'];
일치하는곳의 이름을 지정할 수 있다<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 18:00:23 Regular Expression (정규표현식)에서 이동 됨]</div>
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기
댓글 4개
좋은 정보군요..
$datetime = date_create($s_date); // php 5.0 이상함수
$s_y = date_format($datetime, 'Y'); //처음 날자에서 년도만 가져온다
$s_m = date_format($datetime, 'm'); //처음 날자에서 월만 가져온다
$s_d = date_format($datetime, 'd'); //처음 날자에서 일만 가져온다
이렇게 date_format 함수를 사용했는데
좋아요~
고맙습니다.