PHP 의 strpos 함수에서 검색하는 문자열을 배열로 검색하기 > 개발

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

개발

PHP 의 strpos 함수에서 검색하는 문자열을 배열로 검색하기

페이지 정보

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

본문

Using an array as needles in strpos


function strposa($haystack, $needle, $offset=0) {
    if(!is_array($needle)) $needle = array($needle);
    foreach($needle as $query) {
        if(strpos($haystack, $query, $offset) !== false) return true; // stop on first true result
    }
    return false;
}
$string = 'Whis string contains word "cheese" and "tea".';
$array  = array('burger', 'melon', 'cheese', 'milk');
var_dump(strposa($string, $array)); // will return true, since "cheese" has been found



** 출처 : http://stackoverflow.com/questions/6284553/using-an-array-as-needles-in-strpos

추천0

댓글목록

등록된 댓글이 없습니다.

Total 387건 3 페이지
  • RSS
개발 목록
번호 제목 조회 추천 날짜
3475113012-20
3464998011-27
3454963001-03
3444957003-09
3434929006-04
3424897007-04
3414888004-24
3404875001-11
3394857004-09
3384839005-13
3374815005-29
3364786001-31
3354728005-07
3344717007-29
3334712011-11
3324688007-22
3314678010-10
3304674004-25
3294656005-19
3284648006-10

검색


사이트 정보

Copyright © Baragi.Net. All rights reserved.