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년 전 | 344 | ||
| 8029 | 9년 전 | 281 | ||
| 8028 | 9년 전 | 250 | ||
| 8027 | 9년 전 | 262 | ||
| 8026 | 9년 전 | 303 | ||
| 8025 | 9년 전 | 359 | ||
| 8024 | 9년 전 | 325 | ||
| 8023 | 9년 전 | 377 | ||
| 8022 | 9년 전 | 304 | ||
| 8021 | 9년 전 | 303 | ||
| 8020 | 9년 전 | 301 | ||
| 8019 | 9년 전 | 327 | ||
| 8018 | 9년 전 | 427 | ||
| 8017 | 9년 전 | 525 | ||
| 8016 | 9년 전 | 313 | ||
| 8015 | 9년 전 | 377 | ||
| 8014 | 9년 전 | 311 | ||
| 8013 | 9년 전 | 222 | ||
| 8012 | 9년 전 | 236 | ||
| 8011 | 9년 전 | 435 | ||
| 8010 | 9년 전 | 286 | ||
| 8009 | 9년 전 | 273 | ||
| 8008 | 9년 전 | 274 | ||
| 8007 | 9년 전 | 416 | ||
| 8006 | 9년 전 | 453 | ||
| 8005 |
|
9년 전 | 953 | |
| 8004 | 9년 전 | 336 | ||
| 8003 | 9년 전 | 404 | ||
| 8002 | 9년 전 | 313 | ||
| 8001 |
|
9년 전 | 652 | |
| 8000 | 9년 전 | 397 | ||
| 7999 | 9년 전 | 361 | ||
| 7998 | 9년 전 | 412 | ||
| 7997 | 9년 전 | 301 | ||
| 7996 | 9년 전 | 527 | ||
| 7995 | 9년 전 | 434 | ||
| 7994 | 9년 전 | 275 | ||
| 7993 | 9년 전 | 357 | ||
| 7992 | 9년 전 | 497 | ||
| 7991 | 9년 전 | 231 | ||
| 7990 | 9년 전 | 256 | ||
| 7989 | 9년 전 | 290 | ||
| 7988 | 9년 전 | 712 | ||
| 7987 | 9년 전 | 407 | ||
| 7986 | 9년 전 | 397 | ||
| 7985 | 9년 전 | 489 | ||
| 7984 | 9년 전 | 419 | ||
| 7983 | 9년 전 | 638 | ||
| 7982 | 9년 전 | 500 | ||
| 7981 | 9년 전 | 446 | ||
| 7980 | 9년 전 | 473 | ||
| 7979 | 9년 전 | 448 | ||
| 7978 | 9년 전 | 424 | ||
| 7977 | 9년 전 | 360 | ||
| 7976 | 9년 전 | 832 | ||
| 7975 | 9년 전 | 351 | ||
| 7974 | 9년 전 | 377 | ||
| 7973 | 9년 전 | 582 | ||
| 7972 | 9년 전 | 369 | ||
| 7971 | 9년 전 | 435 | ||
| 7970 | 9년 전 | 283 | ||
| 7969 | 9년 전 | 529 | ||
| 7968 | 9년 전 | 368 | ||
| 7967 | 9년 전 | 349 | ||
| 7966 | 9년 전 | 351 | ||
| 7965 |
|
9년 전 | 1001 | |
| 7964 | 9년 전 | 388 | ||
| 7963 | 9년 전 | 372 | ||
| 7962 | 9년 전 | 357 | ||
| 7961 |
전갈자리남자
|
9년 전 | 496 | |
| 7960 | 9년 전 | 946 | ||
| 7959 | 9년 전 | 539 | ||
| 7958 | 9년 전 | 393 | ||
| 7957 | 9년 전 | 353 | ||
| 7956 | 9년 전 | 362 | ||
| 7955 | 9년 전 | 427 | ||
| 7954 | 9년 전 | 352 | ||
| 7953 | 9년 전 | 411 | ||
| 7952 | 9년 전 | 337 | ||
| 7951 | 9년 전 | 481 | ||
| 7950 | 9년 전 | 368 | ||
| 7949 | 9년 전 | 377 | ||
| 7948 | 9년 전 | 312 | ||
| 7947 | 9년 전 | 915 | ||
| 7946 | 9년 전 | 408 | ||
| 7945 | 9년 전 | 375 | ||
| 7944 | 9년 전 | 383 | ||
| 7943 | 9년 전 | 355 | ||
| 7942 | 9년 전 | 390 | ||
| 7941 | 9년 전 | 375 | ||
| 7940 | 9년 전 | 864 | ||
| 7939 | 9년 전 | 314 | ||
| 7938 | 9년 전 | 360 | ||
| 7937 | 9년 전 | 261 | ||
| 7936 | 9년 전 | 865 | ||
| 7935 | 9년 전 | 418 | ||
| 7934 | 9년 전 | 386 | ||
| 7933 | 9년 전 | 462 | ||
| 7932 | 9년 전 | 438 | ||
| 7931 | 9년 전 | 499 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기