in_array
(PHP 4, PHP 5, PHP 7)
in_array — 값이 배열 안에 존재하는지 확인
설명 ¶
bool in_array ( mixed $needle , array $haystack [, bool $strict ] )
인수 ¶
needle
찾을 값.
Note:
needle이 문자열이면, 대소문자를 구분하여 비교합니다.
haystack
배열.
strict
세번째 인수 strict를 TRUE로 설정하면, in_array() 함수는 haystack 안에서 needle의 자료형도 확인합니다.
반환값 ¶
needle을 배열에서 찾으면 TRUE를, 아니면 FALSE를 반환합니다.
Example #1 in_array() 예제
<?php
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Got Irix";
}
if (in_array("mac", $os)) {
echo "Got mac";
}
?>
in_array()가 대소문자를 구분하므로 두번째 조건은 실패하고, 위 프로그램은 다음을 출력합니다:
output :
Got Irix
Example #2 in_array()에 strict 예제
<?php
$a = array('1.10', 12.4, 1.13);
if (in_array('12.4', $a, true)) {
echo "'12.4' found with strict check\n";
}
if (in_array(1.13, $a, true)) {
echo "1.13 found with strict check\n";
}
?>
위 예제의 출력:
1.13 found with strict check
Example #3 in_array()에 needle로 배열
<?php
$a = array(array('p', 'h'), array('p', 'r'), 'o');
if (in_array(array('p', 'h'), $a)) {
echo "'ph' was found\n";
}
if (in_array(array('f', 'i'), $a)) {
echo "'fi' was found\n";
}
if (in_array('o', $a)) {
echo "'o' was found\n";
}
?>
위 예제의 출력:
'ph' was found
'o' was found
댓글 1개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 130 | 20년 전 | 3977 | ||
| 129 | 20년 전 | 2920 | ||
| 128 | 20년 전 | 3655 | ||
| 127 | 20년 전 | 3477 | ||
| 126 | 20년 전 | 3744 | ||
| 125 | 20년 전 | 8574 | ||
| 124 | 20년 전 | 2596 | ||
| 123 | 20년 전 | 3735 | ||
| 122 | 20년 전 | 3197 | ||
| 121 | 20년 전 | 2601 | ||
| 120 | 20년 전 | 2656 | ||
| 119 | 20년 전 | 2573 | ||
| 118 | 20년 전 | 2858 | ||
| 117 |
|
20년 전 | 3046 | |
| 116 | 20년 전 | 5293 | ||
| 115 | 20년 전 | 3909 | ||
| 114 | 20년 전 | 4956 | ||
| 113 | 20년 전 | 6206 | ||
| 112 | 20년 전 | 7317 | ||
| 111 | 20년 전 | 18425 | ||
| 110 | 20년 전 | 6870 | ||
| 109 | 20년 전 | 2869 | ||
| 108 | 20년 전 | 4134 | ||
| 107 |
prosper
|
20년 전 | 2483 | |
| 106 |
prosper
|
20년 전 | 4309 | |
| 105 |
아우겐나이스
|
20년 전 | 2904 | |
| 104 | 20년 전 | 2254 | ||
| 103 | 20년 전 | 2470 | ||
| 102 | 20년 전 | 2234 | ||
| 101 | 20년 전 | 2563 | ||
| 100 | 20년 전 | 1739 | ||
| 99 | 20년 전 | 1560 | ||
| 98 | 20년 전 | 1614 | ||
| 97 | 20년 전 | 2119 | ||
| 96 | 20년 전 | 1866 | ||
| 95 | 20년 전 | 2367 | ||
| 94 | 20년 전 | 3553 | ||
| 93 | 20년 전 | 1552 | ||
| 92 | 20년 전 | 1747 | ||
| 91 | 20년 전 | 3170 | ||
| 90 | 20년 전 | 2336 | ||
| 89 | 20년 전 | 3161 | ||
| 88 | 20년 전 | 2865 | ||
| 87 | 20년 전 | 3290 | ||
| 86 | 20년 전 | 5115 | ||
| 85 | 20년 전 | 2511 | ||
| 84 | 20년 전 | 4819 | ||
| 83 | 20년 전 | 2497 | ||
| 82 | 20년 전 | 3113 | ||
| 81 | 20년 전 | 7616 | ||
| 80 | 20년 전 | 3812 | ||
| 79 | 20년 전 | 3201 | ||
| 78 | 20년 전 | 4686 | ||
| 77 | 20년 전 | 2891 | ||
| 76 | 20년 전 | 6208 | ||
| 75 | 20년 전 | 4468 | ||
| 74 | 20년 전 | 5773 | ||
| 73 | 20년 전 | 3619 | ||
| 72 | 20년 전 | 5961 | ||
| 71 | 20년 전 | 3103 | ||
| 70 | 20년 전 | 2830 | ||
| 69 | 20년 전 | 2629 | ||
| 68 | 20년 전 | 2439 | ||
| 67 | 20년 전 | 2643 | ||
| 66 | 20년 전 | 2661 | ||
| 65 | 20년 전 | 3782 | ||
| 64 | 20년 전 | 2819 | ||
| 63 | 20년 전 | 2450 | ||
| 62 | 20년 전 | 2256 | ||
| 61 | 20년 전 | 3062 | ||
| 60 | 20년 전 | 3128 | ||
| 59 | 20년 전 | 2505 | ||
| 58 | 20년 전 | 2586 | ||
| 57 | 20년 전 | 2957 | ||
| 56 | 20년 전 | 2309 | ||
| 55 | 20년 전 | 2748 | ||
| 54 | 20년 전 | 2116 | ||
| 53 | 20년 전 | 2343 | ||
| 52 | 20년 전 | 2687 | ||
| 51 |
prosper
|
20년 전 | 2340 | |
| 50 |
prosper
|
20년 전 | 2159 | |
| 49 | 21년 전 | 2171 | ||
| 48 | 21년 전 | 2321 | ||
| 47 | 21년 전 | 1922 | ||
| 46 | 21년 전 | 1920 | ||
| 45 | 21년 전 | 2128 | ||
| 44 | 21년 전 | 2352 | ||
| 43 | 21년 전 | 4567 | ||
| 42 |
prosper
|
21년 전 | 2708 | |
| 41 |
prosper
|
21년 전 | 2107 | |
| 40 | 21년 전 | 2174 | ||
| 39 | 21년 전 | 2138 | ||
| 38 | 21년 전 | 2410 | ||
| 37 | 21년 전 | 2556 | ||
| 36 | 21년 전 | 1768 | ||
| 35 | 21년 전 | 4065 | ||
| 34 | 21년 전 | 3842 | ||
| 33 | 21년 전 | 2985 | ||
| 32 |
prosper
|
21년 전 | 2895 | |
| 31 | 21년 전 | 5266 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기