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년 전 | 399 | ||
| 8029 | 9년 전 | 324 | ||
| 8028 | 9년 전 | 284 | ||
| 8027 | 9년 전 | 293 | ||
| 8026 | 9년 전 | 364 | ||
| 8025 | 9년 전 | 403 | ||
| 8024 | 9년 전 | 370 | ||
| 8023 | 9년 전 | 411 | ||
| 8022 | 9년 전 | 329 | ||
| 8021 | 9년 전 | 348 | ||
| 8020 | 9년 전 | 341 | ||
| 8019 | 9년 전 | 360 | ||
| 8018 | 9년 전 | 462 | ||
| 8017 | 9년 전 | 551 | ||
| 8016 | 9년 전 | 362 | ||
| 8015 | 9년 전 | 405 | ||
| 8014 | 9년 전 | 340 | ||
| 8013 | 9년 전 | 256 | ||
| 8012 | 9년 전 | 261 | ||
| 8011 | 9년 전 | 462 | ||
| 8010 | 9년 전 | 317 | ||
| 8009 | 9년 전 | 326 | ||
| 8008 | 9년 전 | 301 | ||
| 8007 | 9년 전 | 451 | ||
| 8006 | 9년 전 | 486 | ||
| 8005 |
|
9년 전 | 984 | |
| 8004 | 9년 전 | 372 | ||
| 8003 | 9년 전 | 443 | ||
| 8002 | 9년 전 | 337 | ||
| 8001 |
|
9년 전 | 682 | |
| 8000 | 9년 전 | 441 | ||
| 7999 | 9년 전 | 398 | ||
| 7998 | 9년 전 | 451 | ||
| 7997 | 9년 전 | 324 | ||
| 7996 | 9년 전 | 556 | ||
| 7995 | 9년 전 | 491 | ||
| 7994 | 9년 전 | 367 | ||
| 7993 | 9년 전 | 430 | ||
| 7992 | 9년 전 | 532 | ||
| 7991 | 9년 전 | 276 | ||
| 7990 | 9년 전 | 306 | ||
| 7989 | 9년 전 | 322 | ||
| 7988 | 9년 전 | 748 | ||
| 7987 | 9년 전 | 451 | ||
| 7986 | 9년 전 | 447 | ||
| 7985 | 9년 전 | 527 | ||
| 7984 | 9년 전 | 446 | ||
| 7983 | 9년 전 | 689 | ||
| 7982 | 9년 전 | 549 | ||
| 7981 | 9년 전 | 502 | ||
| 7980 | 9년 전 | 522 | ||
| 7979 | 9년 전 | 511 | ||
| 7978 | 9년 전 | 481 | ||
| 7977 | 9년 전 | 417 | ||
| 7976 | 9년 전 | 874 | ||
| 7975 | 9년 전 | 388 | ||
| 7974 | 9년 전 | 416 | ||
| 7973 | 9년 전 | 622 | ||
| 7972 | 9년 전 | 403 | ||
| 7971 | 9년 전 | 475 | ||
| 7970 | 9년 전 | 322 | ||
| 7969 | 9년 전 | 560 | ||
| 7968 | 9년 전 | 404 | ||
| 7967 | 9년 전 | 390 | ||
| 7966 | 9년 전 | 401 | ||
| 7965 |
|
9년 전 | 1035 | |
| 7964 | 9년 전 | 423 | ||
| 7963 | 9년 전 | 431 | ||
| 7962 | 9년 전 | 419 | ||
| 7961 |
전갈자리남자
|
9년 전 | 520 | |
| 7960 | 9년 전 | 987 | ||
| 7959 | 9년 전 | 567 | ||
| 7958 | 9년 전 | 427 | ||
| 7957 | 9년 전 | 381 | ||
| 7956 | 9년 전 | 377 | ||
| 7955 | 9년 전 | 478 | ||
| 7954 | 9년 전 | 406 | ||
| 7953 | 9년 전 | 456 | ||
| 7952 | 9년 전 | 380 | ||
| 7951 | 9년 전 | 517 | ||
| 7950 | 9년 전 | 413 | ||
| 7949 | 9년 전 | 402 | ||
| 7948 | 9년 전 | 341 | ||
| 7947 | 9년 전 | 953 | ||
| 7946 | 9년 전 | 464 | ||
| 7945 | 9년 전 | 417 | ||
| 7944 | 9년 전 | 461 | ||
| 7943 | 9년 전 | 403 | ||
| 7942 | 9년 전 | 420 | ||
| 7941 | 9년 전 | 414 | ||
| 7940 | 9년 전 | 915 | ||
| 7939 | 9년 전 | 388 | ||
| 7938 | 9년 전 | 417 | ||
| 7937 | 9년 전 | 306 | ||
| 7936 | 9년 전 | 900 | ||
| 7935 | 9년 전 | 480 | ||
| 7934 | 9년 전 | 447 | ||
| 7933 | 9년 전 | 565 | ||
| 7932 | 9년 전 | 521 | ||
| 7931 | 9년 전 | 574 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기