Quote:
Originally Posted by OciXCrom
By using dynamic arrays. This is the code I use in nearly all my plugins:
PHP Code:
ReadFile()
{
new szFilename[256]
get_configsdir(szFilename, charsmax(szFilename))
add(szFilename, charsmax(szFilename), "/FileName.ini")
new iFilePointer = fopen(szFilename, "rt")
if(iFilePointer)
{
new szData[128]
new Array:myArray = ArrayCreate(128)
while(!feof(iFilePointer))
{
fgets(iFilePointer, szData, charsmax(szData))
trim(szData)
switch(szData[0])
{
case EOS, ';', '#': continue
default:
{
ArrayPushString(myArray, szData)
}
}
}
for(new i; i < ArraySize(myArray); i++)
{
server_cmd("say %a", ArrayGetStringHandle(myArray, i))
}
ArrayDestroy(myArray)
fclose(iFilePointer)
}
}
|
If i want to use array variable outside this func then i need to make global variable right?
PHP Code:
new Array:myArray = ArrayCreate(128)
__________________