VBScript substr_compare function

A VBScript equivalent of PHP’s substr_compare

Function substr_compare(main_str,str,offset,length, case_insensitivity)

    If len(offset) > 0 Then
        If offset > 0 Then
            main_str = Mid(main_str,offset)
            main_str = Mid(main_str,len(main_str) + offset + 1)
        End If
    End If

    If len(length) > 0 Then
        main_str = Left(main_str,length)
        str = Left(str,length)
    End If
    var_dump main_str
    var_dump str
    If case_insensitivity = true Then
        substr_compare = strcasecmp(main_str,str)
        substr_compare = strcmp(main_str,str)
    End If

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