asp 判斷字符串是否在數組中

function inArray(str,arr)
    inArray=false
    if not isnull(arr) and isarray(arr) then
        for ii=0 to ubound(arr)
            if ucase(trim(arr(ii)))=ucase(trim(str)) then
                inArray=true
                exit function
            end if
        next
    end if
end function

使用

arr= Array("Jan","Feb","Mar","Apr","Sep","Oct", "Nov","Dec")

inArray("Feb",arr)    output true

inArray("May",arr) output false

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章