PHP 에서 값이 배열 안에 존재하는지 확인 in_array > 개발

본문 바로가기
사이트 내 전체검색

개발

PHP 에서 값이 배열 안에 존재하는지 확인 in_array

페이지 정보

profile_image
작성자 관리자 (114.♡.85.207)
댓글 0건 조회 3,077회 작성일 16-04-02 21:43

본문

설명 ¶

bool in_array ( mixed $needle , array $haystack [, bool $strict ] )
haystack에서 needle을 찾습니다.

인수 ¶

needle
찾을 값.

Note:
needle이 문자열이면, 대소문자를 구분하여 비교합니다.
haystack
배열.

strict
세번째 인수 strict를 TRUE로 설정하면, in_array() 함수는 haystack 안에서 needle의 자료형도 확인합니다.


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()가 대소문자를 구분하므로 두번째 조건은 실패하고, 위 프로그램은 다음을 출력합니다:

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


** 출처 : http://php.net/manual/kr/function.in-array.php

추천0

댓글목록

등록된 댓글이 없습니다.

Total 387건 3 페이지
  • RSS
개발 목록
번호 제목 조회 추천 날짜
3475112012-20
3464996011-27
3454959001-03
3444954003-09
3434929006-04
3424895007-04
3414887004-24
3404875001-11
3394857004-09
3384839005-13
3374815005-29
3364784001-31
3354728005-07
3344716007-29
3334712011-11
3324688007-22
3314676010-10
3304674004-25
3294656005-19
3284648006-10

검색


사이트 정보

Copyright © Baragi.Net. All rights reserved.