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년 전 | 412 | ||
| 7929 | 9년 전 | 327 | ||
| 7928 | 9년 전 | 419 | ||
| 7927 | 9년 전 | 335 | ||
| 7926 | 9년 전 | 667 | ||
| 7925 | 9년 전 | 352 | ||
| 7924 | 9년 전 | 336 | ||
| 7923 | 9년 전 | 340 | ||
| 7922 | 9년 전 | 378 | ||
| 7921 | 9년 전 | 397 | ||
| 7920 | 9년 전 | 321 | ||
| 7919 | 9년 전 | 333 | ||
| 7918 | 9년 전 | 488 | ||
| 7917 | 9년 전 | 327 | ||
| 7916 | 9년 전 | 406 | ||
| 7915 | 9년 전 | 402 | ||
| 7914 | 9년 전 | 413 | ||
| 7913 | 9년 전 | 571 | ||
| 7912 | 9년 전 | 419 | ||
| 7911 | 9년 전 | 364 | ||
| 7910 | 9년 전 | 408 | ||
| 7909 | 9년 전 | 505 | ||
| 7908 | 9년 전 | 428 | ||
| 7907 | 9년 전 | 370 | ||
| 7906 | 9년 전 | 392 | ||
| 7905 | 9년 전 | 373 | ||
| 7904 | 9년 전 | 355 | ||
| 7903 | 9년 전 | 344 | ||
| 7902 | 9년 전 | 561 | ||
| 7901 |
|
9년 전 | 733 | |
| 7900 | 9년 전 | 587 | ||
| 7899 | 9년 전 | 381 | ||
| 7898 | 9년 전 | 384 | ||
| 7897 | 9년 전 | 344 | ||
| 7896 | 9년 전 | 359 | ||
| 7895 | 9년 전 | 466 | ||
| 7894 | 9년 전 | 389 | ||
| 7893 | 9년 전 | 335 | ||
| 7892 | 9년 전 | 393 | ||
| 7891 | 9년 전 | 765 | ||
| 7890 | 9년 전 | 1196 | ||
| 7889 | 9년 전 | 746 | ||
| 7888 |
limsy1987
|
9년 전 | 546 | |
| 7887 | 9년 전 | 547 | ||
| 7886 | 9년 전 | 437 | ||
| 7885 | 9년 전 | 404 | ||
| 7884 | 9년 전 | 408 | ||
| 7883 | 9년 전 | 399 | ||
| 7882 | 9년 전 | 449 | ||
| 7881 | 9년 전 | 440 | ||
| 7880 | 9년 전 | 564 | ||
| 7879 | 9년 전 | 460 | ||
| 7878 | 9년 전 | 1217 | ||
| 7877 | 9년 전 | 749 | ||
| 7876 | 9년 전 | 486 | ||
| 7875 | 9년 전 | 559 | ||
| 7874 |
|
9년 전 | 809 | |
| 7873 | 9년 전 | 518 | ||
| 7872 | 9년 전 | 675 | ||
| 7871 | 9년 전 | 482 | ||
| 7870 | 9년 전 | 607 | ||
| 7869 | 9년 전 | 435 | ||
| 7868 | 9년 전 | 445 | ||
| 7867 | 9년 전 | 424 | ||
| 7866 | 9년 전 | 487 | ||
| 7865 | 9년 전 | 453 | ||
| 7864 | 9년 전 | 513 | ||
| 7863 | 9년 전 | 506 | ||
| 7862 | 9년 전 | 465 | ||
| 7861 | 9년 전 | 631 | ||
| 7860 | 9년 전 | 622 | ||
| 7859 | 9년 전 | 409 | ||
| 7858 | 9년 전 | 704 | ||
| 7857 | 9년 전 | 1074 | ||
| 7856 | 9년 전 | 521 | ||
| 7855 | 9년 전 | 751 | ||
| 7854 | 9년 전 | 730 | ||
| 7853 | 9년 전 | 579 | ||
| 7852 | 9년 전 | 508 | ||
| 7851 | 9년 전 | 505 | ||
| 7850 | 9년 전 | 583 | ||
| 7849 | 9년 전 | 356 | ||
| 7848 | 9년 전 | 410 | ||
| 7847 | 9년 전 | 652 | ||
| 7846 | 9년 전 | 454 | ||
| 7845 | 9년 전 | 415 | ||
| 7844 | 9년 전 | 390 | ||
| 7843 | 9년 전 | 414 | ||
| 7842 | 9년 전 | 398 | ||
| 7841 | 9년 전 | 382 | ||
| 7840 | 9년 전 | 405 | ||
| 7839 | 9년 전 | 435 | ||
| 7838 | 9년 전 | 519 | ||
| 7837 | 9년 전 | 356 | ||
| 7836 | 9년 전 | 398 | ||
| 7835 | 9년 전 | 473 | ||
| 7834 |
|
9년 전 | 1192 | |
| 7833 | 9년 전 | 428 | ||
| 7832 | 9년 전 | 415 | ||
| 7831 | 9년 전 | 561 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기