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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 382 | ||
| 7929 | 9년 전 | 280 | ||
| 7928 | 9년 전 | 384 | ||
| 7927 | 9년 전 | 306 | ||
| 7926 | 9년 전 | 652 | ||
| 7925 | 9년 전 | 325 | ||
| 7924 | 9년 전 | 305 | ||
| 7923 | 9년 전 | 327 | ||
| 7922 | 9년 전 | 349 | ||
| 7921 | 9년 전 | 381 | ||
| 7920 | 9년 전 | 302 | ||
| 7919 | 9년 전 | 320 | ||
| 7918 | 9년 전 | 479 | ||
| 7917 | 9년 전 | 319 | ||
| 7916 | 9년 전 | 387 | ||
| 7915 | 9년 전 | 379 | ||
| 7914 | 9년 전 | 391 | ||
| 7913 | 9년 전 | 517 | ||
| 7912 | 9년 전 | 389 | ||
| 7911 | 9년 전 | 335 | ||
| 7910 | 9년 전 | 375 | ||
| 7909 | 9년 전 | 478 | ||
| 7908 | 9년 전 | 378 | ||
| 7907 | 9년 전 | 337 | ||
| 7906 | 9년 전 | 349 | ||
| 7905 | 9년 전 | 339 | ||
| 7904 | 9년 전 | 310 | ||
| 7903 | 9년 전 | 314 | ||
| 7902 | 9년 전 | 523 | ||
| 7901 |
|
9년 전 | 721 | |
| 7900 | 9년 전 | 552 | ||
| 7899 | 9년 전 | 354 | ||
| 7898 | 9년 전 | 348 | ||
| 7897 | 9년 전 | 305 | ||
| 7896 | 9년 전 | 334 | ||
| 7895 | 9년 전 | 437 | ||
| 7894 | 9년 전 | 360 | ||
| 7893 | 9년 전 | 298 | ||
| 7892 | 9년 전 | 347 | ||
| 7891 | 9년 전 | 730 | ||
| 7890 | 9년 전 | 1182 | ||
| 7889 | 9년 전 | 738 | ||
| 7888 |
limsy1987
|
9년 전 | 532 | |
| 7887 | 9년 전 | 516 | ||
| 7886 | 9년 전 | 402 | ||
| 7885 | 9년 전 | 377 | ||
| 7884 | 9년 전 | 381 | ||
| 7883 | 9년 전 | 369 | ||
| 7882 | 9년 전 | 388 | ||
| 7881 | 9년 전 | 407 | ||
| 7880 | 9년 전 | 532 | ||
| 7879 | 9년 전 | 427 | ||
| 7878 | 9년 전 | 1173 | ||
| 7877 | 9년 전 | 722 | ||
| 7876 | 9년 전 | 448 | ||
| 7875 | 9년 전 | 527 | ||
| 7874 |
|
9년 전 | 788 | |
| 7873 | 9년 전 | 486 | ||
| 7872 | 9년 전 | 631 | ||
| 7871 | 9년 전 | 454 | ||
| 7870 | 9년 전 | 585 | ||
| 7869 | 9년 전 | 398 | ||
| 7868 | 9년 전 | 398 | ||
| 7867 | 9년 전 | 394 | ||
| 7866 | 9년 전 | 459 | ||
| 7865 | 9년 전 | 415 | ||
| 7864 | 9년 전 | 477 | ||
| 7863 | 9년 전 | 467 | ||
| 7862 | 9년 전 | 443 | ||
| 7861 | 9년 전 | 601 | ||
| 7860 | 9년 전 | 599 | ||
| 7859 | 9년 전 | 376 | ||
| 7858 | 9년 전 | 681 | ||
| 7857 | 9년 전 | 1035 | ||
| 7856 | 9년 전 | 493 | ||
| 7855 | 9년 전 | 715 | ||
| 7854 | 9년 전 | 705 | ||
| 7853 | 9년 전 | 557 | ||
| 7852 | 9년 전 | 476 | ||
| 7851 | 9년 전 | 460 | ||
| 7850 | 9년 전 | 559 | ||
| 7849 | 9년 전 | 327 | ||
| 7848 | 9년 전 | 379 | ||
| 7847 | 9년 전 | 602 | ||
| 7846 | 9년 전 | 426 | ||
| 7845 | 9년 전 | 379 | ||
| 7844 | 9년 전 | 372 | ||
| 7843 | 9년 전 | 383 | ||
| 7842 | 9년 전 | 373 | ||
| 7841 | 9년 전 | 360 | ||
| 7840 | 9년 전 | 368 | ||
| 7839 | 9년 전 | 408 | ||
| 7838 | 9년 전 | 488 | ||
| 7837 | 9년 전 | 333 | ||
| 7836 | 9년 전 | 372 | ||
| 7835 | 9년 전 | 450 | ||
| 7834 |
|
9년 전 | 1176 | |
| 7833 | 9년 전 | 388 | ||
| 7832 | 9년 전 | 391 | ||
| 7831 | 9년 전 | 522 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기