SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 23/03/2009, 04:28 PM   #1
raymy
Little Clucker
 
Join Date: Aug 2007
Posts: 4
Reputation: 0
Default Count Array Records function

Hey,
I have a little question:
Is there any function to count the number of records in an array?
Like this PHP function: http://php.net/manual/en/function.count.php

PS. I have searched the forum and the wiki, but can't find anything helpful.
raymy is offline  
Old 23/03/2009, 06:40 PM   #2
raymy
Little Clucker
 
Join Date: Aug 2007
Posts: 4
Reputation: 0
Default Re: Count Array Records function

I was thinking this function counts the number of characters in a string, but it counts the number of records in an array? Am I correct?
raymy is offline  
Old 23/03/2009, 10:37 PM   #3
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 3,495
Reputation: 136
Default Re: Count Array Records function

you make a variable, let's say this one
pawn Code:
new myArray[6]; //6 "records" as you call it
then if I do sizeof(myArray), it will return 6.
even if I set like
myArray[0] = 2;
myArray[1] = 6;

It'll still return 6, since the number of arrays will still be the same
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline  
Old 24/03/2009, 02:03 PM   #4
raymy
Little Clucker
 
Join Date: Aug 2007
Posts: 4
Reputation: 0
Default Re: Count Array Records function

Thanks for your reply.
So, is it possible to create an array without defining how much records there will be in?

Is something like this possible?
Code:
new myArray;
myArray['key1'] = "value1";
myArray['key2'] = "value2";
myArray['key3'] = "value3";
myArray['key4'] = "value4";

sizeof(myArray); // Will return 4?
raymy is offline  
Old 25/03/2009, 01:27 PM   #5
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 3,495
Reputation: 136
Default Re: Count Array Records function

if you use new myArray[] yes, if I understanded your question correctly (you still need to create braces)
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline  
 

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Error 010][Array] Invalid function or declaration FoxtrotZulu Help Archive 2 20/07/2010 03:06 PM
Problem with my count down function Ben147 Help Archive 2 03/04/2010 06:36 PM
[QUESTION] Is it possible to return a function an array? Ignas1337 Help Archive 6 23/05/2009 04:32 PM


All times are GMT. The time now is 12:48 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.