Raised This Month: $ Target: $400
 0% 

ArrayFindString Issue


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
ConorCC
Member
Join Date: Feb 2014
Old 12-13-2021 , 17:26   ArrayFindString Issue
Reply With Quote #1

Hey There!

I just realized ArrayFindString will returns the index of the first occurence of the specified string. As it says in the documentation.

If you have an array like:
- de_dust2_long
- de_nuke

And you are looking for a string like:
- de_dust2

The function will returns 0 instead of -1. I know de_dust2 is part of de_dust2_long, but wouldn't be nice a 3rd param of the original function to search exact string or substing?

PHP Code:
ArrayFindStringEx(&Array: WhichszItem[], bExact 1) {

    if ( !
bExact )
        return 
ArrayFindString(WhichszItem);

    new 
szTmpItem[32], iArraySize ArraySize(Which);

    for ( new 
iiArraySize++ ) {

        
ArrayGetString(WhichiszTmpItemcharsmax(szTmpItem));

        if ( 
equal(szItemszTmpItem) )
            return 
i;
    }

    return -
1;

ConorCC is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode