데이타값이..
b00011, b01122, b02233, b03344..... 이렇게 가는데요
정규식으로
무조건 b0 로만 시작하며, 자리수는 4자리만 뽑는 경우 / 즉.. 위의 예에서 b000, b011, b022, b033 만 뺀다
=============
phpschool "BiHon" 님의 답변입니다.
preg_match_all('/b0\d{2}/','b00011, b01122, b02233, b03344',$matches);
print_r($matches[0]);
실행 결과
Array
(
[0] => b000
[1] => b011
[2] => b022
[3] => b033
)
‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥
정규식 사용하지 않아도 됩니다.
$string = 'b00011, b01122, b02233, b03344';
$temp = explode(', ',$string);
foreach ( $temp as $one )
{
if ( substr($one,0,2)!='b0' ) continue;
echo substr($one,0,4).'<br />';
}
실행 결과
b000
b011
b022
b033
‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥
$string = 'b00011, b01122, b02233, b03344';
$temp = explode('b0',$string); array_shift($temp);
foreach ( $temp as $one ) echo 'b0'.substr($one,0,2).'<br />';
실행 결과
b000
b011
b022
b033<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]</div>
b00011, b01122, b02233, b03344..... 이렇게 가는데요
정규식으로
무조건 b0 로만 시작하며, 자리수는 4자리만 뽑는 경우 / 즉.. 위의 예에서 b000, b011, b022, b033 만 뺀다
=============
phpschool "BiHon" 님의 답변입니다.
preg_match_all('/b0\d{2}/','b00011, b01122, b02233, b03344',$matches);
print_r($matches[0]);
실행 결과
Array
(
[0] => b000
[1] => b011
[2] => b022
[3] => b033
)
‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥
정규식 사용하지 않아도 됩니다.
$string = 'b00011, b01122, b02233, b03344';
$temp = explode(', ',$string);
foreach ( $temp as $one )
{
if ( substr($one,0,2)!='b0' ) continue;
echo substr($one,0,4).'<br />';
}
실행 결과
b000
b011
b022
b033
‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥
$string = 'b00011, b01122, b02233, b03344';
$temp = explode('b0',$string); array_shift($temp);
foreach ( $temp as $one ) echo 'b0'.substr($one,0,2).'<br />';
실행 결과
b000
b011
b022
b033<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]</div>
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기