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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 330 |
prosper
|
20년 전 | 2249 | |
| 329 |
prosper
|
20년 전 | 1858 | |
| 328 |
prosper
|
20년 전 | 1671 | |
| 327 | 20년 전 | 3750 | ||
| 326 | 20년 전 | 4828 | ||
| 325 |
hwatta
|
20년 전 | 2454 | |
| 324 |
|
20년 전 | 3123 | |
| 323 | 20년 전 | 5833 | ||
| 322 |
hwatta
|
20년 전 | 2825 | |
| 321 |
hwatta
|
20년 전 | 2300 | |
| 320 |
yesmoa
|
20년 전 | 4560 | |
| 319 | 20년 전 | 2663 | ||
| 318 | 20년 전 | 2229 | ||
| 317 |
kyodon
|
20년 전 | 2754 | |
| 316 | 20년 전 | 2560 | ||
| 315 |
|
20년 전 | 2870 | |
| 314 |
|
20년 전 | 3322 | |
| 313 |
|
20년 전 | 2626 | |
| 312 |
yesmoa
|
20년 전 | 4700 | |
| 311 | 20년 전 | 3246 | ||
| 310 |
홀로남은자
|
20년 전 | 4543 | |
| 309 | 20년 전 | 2998 | ||
| 308 | 20년 전 | 4114 | ||
| 307 | 20년 전 | 4344 | ||
| 306 | 20년 전 | 7018 | ||
| 305 | 20년 전 | 3859 | ||
| 304 | 20년 전 | 2748 | ||
| 303 |
크리스탈처럼
|
20년 전 | 4383 | |
| 302 | 20년 전 | 2194 | ||
| 301 |
|
20년 전 | 4312 | |
| 300 | 20년 전 | 3776 | ||
| 299 | 20년 전 | 2585 | ||
| 298 | 20년 전 | 4810 | ||
| 297 |
|
20년 전 | 2514 | |
| 296 | 20년 전 | 4510 | ||
| 295 | 20년 전 | 3557 | ||
| 294 | 20년 전 | 3581 | ||
| 293 | 20년 전 | 3806 | ||
| 292 | 20년 전 | 3194 | ||
| 291 |
yesmoa
|
20년 전 | 5920 | |
| 290 | 20년 전 | 2929 | ||
| 289 | 20년 전 | 5833 | ||
| 288 |
|
20년 전 | 2362 | |
| 287 |
|
20년 전 | 1776 | |
| 286 |
|
20년 전 | 2130 | |
| 285 |
|
20년 전 | 3527 | |
| 284 |
|
20년 전 | 2026 | |
| 283 |
|
20년 전 | 4394 | |
| 282 | 20년 전 | 3375 | ||
| 281 |
|
20년 전 | 2195 | |
| 280 |
|
20년 전 | 7790 | |
| 279 | 20년 전 | 5531 | ||
| 278 | 20년 전 | 2977 | ||
| 277 |
|
20년 전 | 5561 | |
| 276 | 20년 전 | 2347 | ||
| 275 | 20년 전 | 2592 | ||
| 274 | 20년 전 | 2362 | ||
| 273 | 20년 전 | 2205 | ||
| 272 | 20년 전 | 2132 | ||
| 271 | 20년 전 | 2593 | ||
| 270 | 20년 전 | 2600 | ||
| 269 | 20년 전 | 2470 | ||
| 268 | 20년 전 | 2666 | ||
| 267 | 20년 전 | 2352 | ||
| 266 | 20년 전 | 2557 | ||
| 265 | 20년 전 | 3490 | ||
| 264 |
|
20년 전 | 5344 | |
| 263 |
|
20년 전 | 3711 | |
| 262 | 20년 전 | 3162 | ||
| 261 |
허저비
|
20년 전 | 5911 | |
| 260 |
|
20년 전 | 5705 | |
| 259 | 20년 전 | 4127 | ||
| 258 | 20년 전 | 2369 | ||
| 257 | 20년 전 | 3175 | ||
| 256 | 20년 전 | 1891 | ||
| 255 | 20년 전 | 1555 | ||
| 254 | 20년 전 | 3129 | ||
| 253 | 20년 전 | 3539 | ||
| 252 | 20년 전 | 5109 | ||
| 251 | 20년 전 | 5795 | ||
| 250 | 20년 전 | 3667 | ||
| 249 | 20년 전 | 5007 | ||
| 248 | 20년 전 | 3273 | ||
| 247 | 20년 전 | 3625 | ||
| 246 |
|
20년 전 | 7938 | |
| 245 |
|
20년 전 | 5892 | |
| 244 | 20년 전 | 4474 | ||
| 243 |
|
20년 전 | 4039 | |
| 242 | 20년 전 | 2767 | ||
| 241 | 20년 전 | 2706 | ||
| 240 | 20년 전 | 2348 | ||
| 239 | 20년 전 | 1645 | ||
| 238 |
아우겐나이스
|
20년 전 | 2250 | |
| 237 |
email
|
20년 전 | 3674 | |
| 236 | 20년 전 | 4137 | ||
| 235 | 20년 전 | 10454 | ||
| 234 | 20년 전 | 5050 | ||
| 233 | 20년 전 | 3358 | ||
| 232 | 20년 전 | 3190 | ||
| 231 | 20년 전 | 3823 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기