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년 전 | 354 | ||
| 8029 | 9년 전 | 286 | ||
| 8028 | 9년 전 | 254 | ||
| 8027 | 9년 전 | 266 | ||
| 8026 | 9년 전 | 309 | ||
| 8025 | 9년 전 | 367 | ||
| 8024 | 9년 전 | 333 | ||
| 8023 | 9년 전 | 380 | ||
| 8022 | 9년 전 | 310 | ||
| 8021 | 9년 전 | 314 | ||
| 8020 | 9년 전 | 307 | ||
| 8019 | 9년 전 | 330 | ||
| 8018 | 9년 전 | 436 | ||
| 8017 | 9년 전 | 530 | ||
| 8016 | 9년 전 | 317 | ||
| 8015 | 9년 전 | 381 | ||
| 8014 | 9년 전 | 314 | ||
| 8013 | 9년 전 | 227 | ||
| 8012 | 9년 전 | 236 | ||
| 8011 | 9년 전 | 435 | ||
| 8010 | 9년 전 | 289 | ||
| 8009 | 9년 전 | 273 | ||
| 8008 | 9년 전 | 278 | ||
| 8007 | 9년 전 | 420 | ||
| 8006 | 9년 전 | 454 | ||
| 8005 |
|
9년 전 | 956 | |
| 8004 | 9년 전 | 341 | ||
| 8003 | 9년 전 | 412 | ||
| 8002 | 9년 전 | 317 | ||
| 8001 |
|
9년 전 | 660 | |
| 8000 | 9년 전 | 404 | ||
| 7999 | 9년 전 | 365 | ||
| 7998 | 9년 전 | 418 | ||
| 7997 | 9년 전 | 304 | ||
| 7996 | 9년 전 | 529 | ||
| 7995 | 9년 전 | 444 | ||
| 7994 | 9년 전 | 291 | ||
| 7993 | 9년 전 | 364 | ||
| 7992 | 9년 전 | 499 | ||
| 7991 | 9년 전 | 240 | ||
| 7990 | 9년 전 | 261 | ||
| 7989 | 9년 전 | 293 | ||
| 7988 | 9년 전 | 718 | ||
| 7987 | 9년 전 | 412 | ||
| 7986 | 9년 전 | 401 | ||
| 7985 | 9년 전 | 501 | ||
| 7984 | 9년 전 | 421 | ||
| 7983 | 9년 전 | 642 | ||
| 7982 | 9년 전 | 504 | ||
| 7981 | 9년 전 | 451 | ||
| 7980 | 9년 전 | 479 | ||
| 7979 | 9년 전 | 452 | ||
| 7978 | 9년 전 | 433 | ||
| 7977 | 9년 전 | 373 | ||
| 7976 | 9년 전 | 844 | ||
| 7975 | 9년 전 | 353 | ||
| 7974 | 9년 전 | 384 | ||
| 7973 | 9년 전 | 584 | ||
| 7972 | 9년 전 | 370 | ||
| 7971 | 9년 전 | 446 | ||
| 7970 | 9년 전 | 285 | ||
| 7969 | 9년 전 | 532 | ||
| 7968 | 9년 전 | 370 | ||
| 7967 | 9년 전 | 358 | ||
| 7966 | 9년 전 | 361 | ||
| 7965 |
|
9년 전 | 1007 | |
| 7964 | 9년 전 | 391 | ||
| 7963 | 9년 전 | 380 | ||
| 7962 | 9년 전 | 362 | ||
| 7961 |
전갈자리남자
|
9년 전 | 499 | |
| 7960 | 9년 전 | 954 | ||
| 7959 | 9년 전 | 544 | ||
| 7958 | 9년 전 | 400 | ||
| 7957 | 9년 전 | 360 | ||
| 7956 | 9년 전 | 364 | ||
| 7955 | 9년 전 | 435 | ||
| 7954 | 9년 전 | 362 | ||
| 7953 | 9년 전 | 418 | ||
| 7952 | 9년 전 | 345 | ||
| 7951 | 9년 전 | 491 | ||
| 7950 | 9년 전 | 379 | ||
| 7949 | 9년 전 | 381 | ||
| 7948 | 9년 전 | 316 | ||
| 7947 | 9년 전 | 922 | ||
| 7946 | 9년 전 | 413 | ||
| 7945 | 9년 전 | 383 | ||
| 7944 | 9년 전 | 396 | ||
| 7943 | 9년 전 | 360 | ||
| 7942 | 9년 전 | 399 | ||
| 7941 | 9년 전 | 379 | ||
| 7940 | 9년 전 | 871 | ||
| 7939 | 9년 전 | 333 | ||
| 7938 | 9년 전 | 366 | ||
| 7937 | 9년 전 | 268 | ||
| 7936 | 9년 전 | 871 | ||
| 7935 | 9년 전 | 430 | ||
| 7934 | 9년 전 | 396 | ||
| 7933 | 9년 전 | 483 | ||
| 7932 | 9년 전 | 455 | ||
| 7931 | 9년 전 | 512 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기