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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 330 |
prosper
|
20년 전 | 2257 | |
| 329 |
prosper
|
20년 전 | 1877 | |
| 328 |
prosper
|
20년 전 | 1684 | |
| 327 | 20년 전 | 3751 | ||
| 326 | 20년 전 | 4840 | ||
| 325 |
hwatta
|
20년 전 | 2465 | |
| 324 |
|
20년 전 | 3134 | |
| 323 | 20년 전 | 5845 | ||
| 322 |
hwatta
|
20년 전 | 2833 | |
| 321 |
hwatta
|
20년 전 | 2308 | |
| 320 |
yesmoa
|
20년 전 | 4562 | |
| 319 | 20년 전 | 2674 | ||
| 318 | 20년 전 | 2233 | ||
| 317 |
kyodon
|
20년 전 | 2756 | |
| 316 | 20년 전 | 2570 | ||
| 315 |
|
20년 전 | 2876 | |
| 314 |
|
20년 전 | 3329 | |
| 313 |
|
20년 전 | 2633 | |
| 312 |
yesmoa
|
20년 전 | 4705 | |
| 311 | 20년 전 | 3258 | ||
| 310 |
홀로남은자
|
20년 전 | 4554 | |
| 309 | 20년 전 | 3002 | ||
| 308 | 20년 전 | 4119 | ||
| 307 | 20년 전 | 4359 | ||
| 306 | 20년 전 | 7024 | ||
| 305 | 20년 전 | 3864 | ||
| 304 | 20년 전 | 2758 | ||
| 303 |
크리스탈처럼
|
20년 전 | 4388 | |
| 302 | 20년 전 | 2199 | ||
| 301 |
|
20년 전 | 4314 | |
| 300 | 20년 전 | 3792 | ||
| 299 | 20년 전 | 2595 | ||
| 298 | 20년 전 | 4816 | ||
| 297 |
|
20년 전 | 2521 | |
| 296 | 20년 전 | 4520 | ||
| 295 | 20년 전 | 3564 | ||
| 294 | 20년 전 | 3586 | ||
| 293 | 20년 전 | 3813 | ||
| 292 | 20년 전 | 3198 | ||
| 291 |
yesmoa
|
20년 전 | 5933 | |
| 290 | 20년 전 | 2931 | ||
| 289 | 20년 전 | 5843 | ||
| 288 |
|
20년 전 | 2371 | |
| 287 |
|
20년 전 | 1789 | |
| 286 |
|
20년 전 | 2139 | |
| 285 |
|
20년 전 | 3529 | |
| 284 |
|
20년 전 | 2028 | |
| 283 |
|
20년 전 | 4399 | |
| 282 | 20년 전 | 3380 | ||
| 281 |
|
20년 전 | 2204 | |
| 280 |
|
20년 전 | 7795 | |
| 279 | 20년 전 | 5543 | ||
| 278 | 20년 전 | 2986 | ||
| 277 |
|
20년 전 | 5567 | |
| 276 | 20년 전 | 2354 | ||
| 275 | 20년 전 | 2598 | ||
| 274 | 20년 전 | 2375 | ||
| 273 | 20년 전 | 2209 | ||
| 272 | 20년 전 | 2146 | ||
| 271 | 20년 전 | 2597 | ||
| 270 | 20년 전 | 2618 | ||
| 269 | 20년 전 | 2477 | ||
| 268 | 20년 전 | 2676 | ||
| 267 | 20년 전 | 2360 | ||
| 266 | 20년 전 | 2560 | ||
| 265 | 20년 전 | 3498 | ||
| 264 |
|
20년 전 | 5357 | |
| 263 |
|
20년 전 | 3721 | |
| 262 | 20년 전 | 3169 | ||
| 261 |
허저비
|
20년 전 | 5921 | |
| 260 |
|
20년 전 | 5710 | |
| 259 | 20년 전 | 4134 | ||
| 258 | 20년 전 | 2375 | ||
| 257 | 20년 전 | 3185 | ||
| 256 | 20년 전 | 1895 | ||
| 255 | 20년 전 | 1562 | ||
| 254 | 20년 전 | 3139 | ||
| 253 | 20년 전 | 3542 | ||
| 252 | 20년 전 | 5117 | ||
| 251 | 20년 전 | 5804 | ||
| 250 | 20년 전 | 3671 | ||
| 249 | 20년 전 | 5012 | ||
| 248 | 20년 전 | 3278 | ||
| 247 | 20년 전 | 3633 | ||
| 246 |
|
20년 전 | 7946 | |
| 245 |
|
20년 전 | 5901 | |
| 244 | 20년 전 | 4485 | ||
| 243 |
|
20년 전 | 4047 | |
| 242 | 20년 전 | 2781 | ||
| 241 | 20년 전 | 2720 | ||
| 240 | 20년 전 | 2359 | ||
| 239 | 20년 전 | 1655 | ||
| 238 |
아우겐나이스
|
20년 전 | 2262 | |
| 237 |
email
|
20년 전 | 3685 | |
| 236 | 20년 전 | 4148 | ||
| 235 | 20년 전 | 10459 | ||
| 234 | 20년 전 | 5065 | ||
| 233 | 20년 전 | 3365 | ||
| 232 | 20년 전 | 3199 | ||
| 231 | 20년 전 | 3837 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기