SA-MP Forums Archive
Count Array Records function - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Count Array Records function (/showthread.php?tid=70292)



Count Array Records function - raymy - 23.03.2009

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.


Re: Count Array Records function - raymy - 23.03.2009

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?


Re: Count Array Records function - LarzI - 23.03.2009

you make a variable, let's say this one
pawn Код:
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


Re: Count Array Records function - raymy - 24.03.2009

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?
Код:
new myArray;
myArray['key1'] = "value1";
myArray['key2'] = "value2";
myArray['key3'] = "value3";
myArray['key4'] = "value4";

sizeof(myArray); // Will return 4?



Re: Count Array Records function - LarzI - 25.03.2009

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