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년 전 | 3989 | ||
| 129 | 20년 전 | 2927 | ||
| 128 | 20년 전 | 3665 | ||
| 127 | 20년 전 | 3491 | ||
| 126 | 20년 전 | 3752 | ||
| 125 | 20년 전 | 8582 | ||
| 124 | 20년 전 | 2597 | ||
| 123 | 20년 전 | 3742 | ||
| 122 | 20년 전 | 3204 | ||
| 121 | 20년 전 | 2606 | ||
| 120 | 20년 전 | 2663 | ||
| 119 | 20년 전 | 2578 | ||
| 118 | 20년 전 | 2858 | ||
| 117 |
|
20년 전 | 3050 | |
| 116 | 20년 전 | 5300 | ||
| 115 | 20년 전 | 3915 | ||
| 114 | 20년 전 | 4964 | ||
| 113 | 20년 전 | 6206 | ||
| 112 | 20년 전 | 7319 | ||
| 111 | 20년 전 | 18427 | ||
| 110 | 20년 전 | 6870 | ||
| 109 | 20년 전 | 2871 | ||
| 108 | 20년 전 | 4136 | ||
| 107 |
prosper
|
20년 전 | 2489 | |
| 106 |
prosper
|
20년 전 | 4314 | |
| 105 |
아우겐나이스
|
20년 전 | 2907 | |
| 104 | 20년 전 | 2255 | ||
| 103 | 20년 전 | 2473 | ||
| 102 | 20년 전 | 2244 | ||
| 101 | 20년 전 | 2570 | ||
| 100 | 20년 전 | 1742 | ||
| 99 | 20년 전 | 1562 | ||
| 98 | 20년 전 | 1614 | ||
| 97 | 20년 전 | 2126 | ||
| 96 | 20년 전 | 1869 | ||
| 95 | 20년 전 | 2368 | ||
| 94 | 20년 전 | 3562 | ||
| 93 | 20년 전 | 1557 | ||
| 92 | 20년 전 | 1751 | ||
| 91 | 20년 전 | 3177 | ||
| 90 | 20년 전 | 2339 | ||
| 89 | 20년 전 | 3166 | ||
| 88 | 20년 전 | 2868 | ||
| 87 | 20년 전 | 3292 | ||
| 86 | 20년 전 | 5126 | ||
| 85 | 20년 전 | 2515 | ||
| 84 | 20년 전 | 4821 | ||
| 83 | 20년 전 | 2499 | ||
| 82 | 20년 전 | 3117 | ||
| 81 | 20년 전 | 7618 | ||
| 80 | 20년 전 | 3819 | ||
| 79 | 20년 전 | 3205 | ||
| 78 | 20년 전 | 4690 | ||
| 77 | 20년 전 | 2893 | ||
| 76 | 20년 전 | 6213 | ||
| 75 | 20년 전 | 4470 | ||
| 74 | 20년 전 | 5777 | ||
| 73 | 20년 전 | 3622 | ||
| 72 | 20년 전 | 5964 | ||
| 71 | 20년 전 | 3110 | ||
| 70 | 20년 전 | 2833 | ||
| 69 | 20년 전 | 2634 | ||
| 68 | 20년 전 | 2443 | ||
| 67 | 20년 전 | 2648 | ||
| 66 | 20년 전 | 2666 | ||
| 65 | 20년 전 | 3783 | ||
| 64 | 20년 전 | 2820 | ||
| 63 | 20년 전 | 2452 | ||
| 62 | 20년 전 | 2261 | ||
| 61 | 20년 전 | 3066 | ||
| 60 | 20년 전 | 3129 | ||
| 59 | 20년 전 | 2509 | ||
| 58 | 20년 전 | 2587 | ||
| 57 | 20년 전 | 2962 | ||
| 56 | 20년 전 | 2314 | ||
| 55 | 20년 전 | 2758 | ||
| 54 | 20년 전 | 2124 | ||
| 53 | 20년 전 | 2346 | ||
| 52 | 20년 전 | 2693 | ||
| 51 |
prosper
|
21년 전 | 2346 | |
| 50 |
prosper
|
21년 전 | 2166 | |
| 49 | 21년 전 | 2174 | ||
| 48 | 21년 전 | 2329 | ||
| 47 | 21년 전 | 1927 | ||
| 46 | 21년 전 | 1927 | ||
| 45 | 21년 전 | 2130 | ||
| 44 | 21년 전 | 2355 | ||
| 43 | 21년 전 | 4568 | ||
| 42 |
prosper
|
21년 전 | 2712 | |
| 41 |
prosper
|
21년 전 | 2110 | |
| 40 | 21년 전 | 2178 | ||
| 39 | 21년 전 | 2141 | ||
| 38 | 21년 전 | 2416 | ||
| 37 | 21년 전 | 2563 | ||
| 36 | 21년 전 | 1769 | ||
| 35 | 21년 전 | 4069 | ||
| 34 | 21년 전 | 3849 | ||
| 33 | 21년 전 | 2989 | ||
| 32 |
prosper
|
21년 전 | 2898 | |
| 31 | 21년 전 | 5273 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기