Jump to content
Sign in to follow this  


Recommended Posts

This function combines the features of two different versions of _ArraySearch().

TheGuy0000's _ArraySearch()

SolidSnake's _ArraySearchAnyDim()

It has support for advaced search criteria (thanks to TheGuy0000) and multidimensional support.

; Description:      Finds an entry within a single or multi-dimensional array. (Similar to _ArrayBinarySearch() except the array does not need to be sorted and it includes multi-dimensional array support and more advanced search features)
; Syntax:           _ArraySearch($avArray, $vWhat2Find, $iStart = 0, $iEnd = 0,$iCaseSense=0,$sDimString )
; Parameter(s):      $avArray               = The array to search
;                    $vWhat2Find            = What to search $avArray for
;                    $iStart (Optional)     = Start array index for search, normally set to 0 or 1. If omitted it is set to 0
;                    $iEnd  (Optional)      = End array index for search. If omitted or set to 0 it is set to Ubound($AvArray)-1
;                    $iCaseSense (Optional) = If set to 1 then search is case sensitive
;                    $iFlag (Optional)      = How to match the search string.
;                    $sDimString            = A speically formated string that allows multidimensional seacrhing 
;                  Possible Values:
;                    0 - (Default) Exact match
;                    1 - match at beginning of element
;                    2 - match at end of element
;                    3 - anywhere in element
;                    4 - Regular Expression (if used, $iCaseSense is ignored)
; Requirement(s):   None
; Return Value(s):  On Success - Returns the position of an item in an array.
;                   On Failure - Returns an -1 if $vWhat2Find is not found
;                   @Error=1 $avArray is not an array
;                   @Error=2 $iStart is greater than UBound($AvArray)-1
;                   @Error=3 $iEnd is greater than UBound($AvArray)-1
;                   @Error=4 $iStart is greater than $iEnd
;                   @Error=5 $iCaseSense was invalid. (Must be 0 or 1)
;                   @Error=6 $vWhat2Find was not found in $avArray
;                   @Error=7 Invalid $iFlag parameter
;                   @Error=8 Invalid $sDimString
; Author(s):        SolidSnake <metalgx91 at gmail dot com>
;                   TheGuy0000 <theguy0000 at gmail dot com>
; Note(s):          This might be slower than _ArrayBinarySearch() but is useful when the array's order can't be altered and or you need advanced features 
;                   $sDimString should look something like this,"[0][X]","X" is used to tell the function to search thorugh the array at that dimension.
Edited by P5ych0Gigabyte

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...