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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8030 | 9년 전 | 386 | ||
| 8029 | 9년 전 | 315 | ||
| 8028 | 9년 전 | 273 | ||
| 8027 | 9년 전 | 287 | ||
| 8026 | 9년 전 | 351 | ||
| 8025 | 9년 전 | 392 | ||
| 8024 | 9년 전 | 351 | ||
| 8023 | 9년 전 | 399 | ||
| 8022 | 9년 전 | 324 | ||
| 8021 | 9년 전 | 334 | ||
| 8020 | 9년 전 | 326 | ||
| 8019 | 9년 전 | 347 | ||
| 8018 | 9년 전 | 451 | ||
| 8017 | 9년 전 | 540 | ||
| 8016 | 9년 전 | 340 | ||
| 8015 | 9년 전 | 396 | ||
| 8014 | 9년 전 | 329 | ||
| 8013 | 9년 전 | 244 | ||
| 8012 | 9년 전 | 250 | ||
| 8011 | 9년 전 | 452 | ||
| 8010 | 9년 전 | 308 | ||
| 8009 | 9년 전 | 301 | ||
| 8008 | 9년 전 | 292 | ||
| 8007 | 9년 전 | 435 | ||
| 8006 | 9년 전 | 469 | ||
| 8005 |
|
9년 전 | 974 | |
| 8004 | 9년 전 | 365 | ||
| 8003 | 9년 전 | 428 | ||
| 8002 | 9년 전 | 325 | ||
| 8001 |
|
9년 전 | 668 | |
| 8000 | 9년 전 | 428 | ||
| 7999 | 9년 전 | 380 | ||
| 7998 | 9년 전 | 437 | ||
| 7997 | 9년 전 | 318 | ||
| 7996 | 9년 전 | 539 | ||
| 7995 | 9년 전 | 463 | ||
| 7994 | 9년 전 | 342 | ||
| 7993 | 9년 전 | 404 | ||
| 7992 | 9년 전 | 519 | ||
| 7991 | 9년 전 | 260 | ||
| 7990 | 9년 전 | 299 | ||
| 7989 | 9년 전 | 312 | ||
| 7988 | 9년 전 | 736 | ||
| 7987 | 9년 전 | 436 | ||
| 7986 | 9년 전 | 432 | ||
| 7985 | 9년 전 | 514 | ||
| 7984 | 9년 전 | 437 | ||
| 7983 | 9년 전 | 667 | ||
| 7982 | 9년 전 | 532 | ||
| 7981 | 9년 전 | 483 | ||
| 7980 | 9년 전 | 503 | ||
| 7979 | 9년 전 | 486 | ||
| 7978 | 9년 전 | 459 | ||
| 7977 | 9년 전 | 399 | ||
| 7976 | 9년 전 | 855 | ||
| 7975 | 9년 전 | 369 | ||
| 7974 | 9년 전 | 402 | ||
| 7973 | 9년 전 | 604 | ||
| 7972 | 9년 전 | 391 | ||
| 7971 | 9년 전 | 465 | ||
| 7970 | 9년 전 | 308 | ||
| 7969 | 9년 전 | 549 | ||
| 7968 | 9년 전 | 391 | ||
| 7967 | 9년 전 | 380 | ||
| 7966 | 9년 전 | 377 | ||
| 7965 |
|
9년 전 | 1020 | |
| 7964 | 9년 전 | 406 | ||
| 7963 | 9년 전 | 406 | ||
| 7962 | 9년 전 | 392 | ||
| 7961 |
전갈자리남자
|
9년 전 | 511 | |
| 7960 | 9년 전 | 973 | ||
| 7959 | 9년 전 | 557 | ||
| 7958 | 9년 전 | 413 | ||
| 7957 | 9년 전 | 371 | ||
| 7956 | 9년 전 | 372 | ||
| 7955 | 9년 전 | 465 | ||
| 7954 | 9년 전 | 388 | ||
| 7953 | 9년 전 | 440 | ||
| 7952 | 9년 전 | 361 | ||
| 7951 | 9년 전 | 506 | ||
| 7950 | 9년 전 | 400 | ||
| 7949 | 9년 전 | 392 | ||
| 7948 | 9년 전 | 329 | ||
| 7947 | 9년 전 | 944 | ||
| 7946 | 9년 전 | 446 | ||
| 7945 | 9년 전 | 402 | ||
| 7944 | 9년 전 | 434 | ||
| 7943 | 9년 전 | 390 | ||
| 7942 | 9년 전 | 410 | ||
| 7941 | 9년 전 | 402 | ||
| 7940 | 9년 전 | 893 | ||
| 7939 | 9년 전 | 361 | ||
| 7938 | 9년 전 | 398 | ||
| 7937 | 9년 전 | 291 | ||
| 7936 | 9년 전 | 889 | ||
| 7935 | 9년 전 | 456 | ||
| 7934 | 9년 전 | 426 | ||
| 7933 | 9년 전 | 534 | ||
| 7932 | 9년 전 | 499 | ||
| 7931 | 9년 전 | 549 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기