케이스 :. 문자를 구분
<?php
$subject = "hello my car is blue and my shoe is blue";
$pattern = '/blue|red|orange|purple/';
preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE);
if (!empty($matches)) {
echo 'Matched `' . $matches[0][0] . '` at index `' . $matches[0][1] . '`';
} else {
echo 'Nothing matched';
}
?>
케이스 :
<?php
$subject = "hello my car is blue and my shoe is blue";
$pattern = '/blue|red|orange|purple/';
preg_match(strtolower($pattern), strtolower($subject), $matches, PREG_OFFSET_CAPTURE);
if (!empty($matches)) {
echo 'Matched `' . $matches[0][0] . '` at index `' . $matches[0][1] . '`';
} else {
echo 'Nothing matched';
}
?>
죄송합니다, 확실히하지 않는다 그것 : 당신의 끈이'나의 차가 파랗고 나의 단화가 파랗다'인 경우에, 무슨 shou 돌려 주겠습니까? – raina77ow
파랑, 첫 번째 것을 찾고 반환 – Latox
좋아,하지만 그때 문제가 뭐야? 두 코드 모두 동일한 코드입니다. – raina77ow