VBScript strpbrk function

A VBScript equivalent of PHP’s strpbrk


Function strpbrk( haystack, char_list )

    haystack  = Cstr( haystack )
    char_list = Cstr( char_list )

    Dim intlen : intlen = len( haystack )
    Dim i,char
    For i = 1 to intlen
        char = Mid(haystack,i,1)
        If [!==](strpos(char_list,char,"),false) Then
            strpbrk = Mid(haystack,i)
            Exit Function
        End If
    Next

    strpbrk = false

End Function

Please also note that php.vbs offers community built functions and goes by the McDonald’s Theory. We’ll put online functions that are far from perfect, in the hopes to spark better contributions. Do you have one? Then please just:

Other PHP functions in the strings extension