Raised This Month: $51 Target: $400
 12% 

Ignore empty rows


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sn!ff3r
Veteran Member
Join Date: Aug 2007
Location: Poland
Old 08-11-2009 , 15:15   Ignore empty rows
Reply With Quote #1

Hi.

PHP Code:
new myarray[10][32]

public function()
{
    for ( new 
08i++)
    {
        
formatex(myarray[i], 31"anytext")
    }

Now two last rows are empty. How to count only set rows ? sizeof will return 10.
__________________
Join US - custom Zombie Server - Custom Addons:



Sn!ff3r is offline
Send a message via Skype™ to Sn!ff3r
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-11-2009 , 15:25   Re: Ignore empty rows
Reply With Quote #2

Does this array hold strings? If not, what kind of data is it?

If strings:
PHP Code:
new myarray[10][32]

public function()
{
    for ( new 
sizeofmyarray ) ; i++ )
        if ( 
myarray[i][0] )
            
formatexmyarray[i] , 31"anytext")

__________________

Last edited by Bugsy; 08-11-2009 at 15:40.
Bugsy is offline
Sn!ff3r
Veteran Member
Join Date: Aug 2007
Location: Poland
Old 08-13-2009 , 13:26   Re: Ignore empty rows
Reply With Quote #3

No, not that!

I want to check real array (not empty rows) size, not fill it.
__________________
Join US - custom Zombie Server - Custom Addons:



Sn!ff3r is offline
Send a message via Skype™ to Sn!ff3r
Jon
Veteran Member
Join Date: Dec 2007
Old 08-13-2009 , 13:46   Re: Ignore empty rows
Reply With Quote #4

strlen( szString[] ) ?
Jon is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 08-13-2009 , 14:10   Re: Ignore empty rows
Reply With Quote #5

more faster do MyArray[i][0] == '\0' ( '^0' )
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 08-13-2009 , 14:22   Re: Ignore empty rows
Reply With Quote #6

...which is the same as ( ! MyArray[i][0] ).

Sn!ff3r explain more.
[ --<-@ ] Black Rose is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-13-2009 , 19:42   Re: Ignore empty rows
Reply With Quote #7

Unfortunately, there is no sizeof-esque operator that will return only array elements that contain data -- you will need to create it yourself.

If you are working with an array of strings then the above will be the simplest method. If the array holds integers (or w\e data) then you will have to determine the best way -- or give us more info on what kind of data you're working with and we can help.
__________________
Bugsy is offline
Reply



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 12:24.


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