SA-MP Forums Archive
Array print - 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)
+--- Thread: Array print (/showthread.php?tid=607306)



Array print - bgedition - 17.05.2016

Hi people,
Is it possible to print 2 dimensional array?

This is my array:
Код:
	//How can I print this below ↓
	new Array[][] = {"1", "2", "3", "4"};



Re: Array print - Konstantinos - 17.05.2016

In an example as the above (let's say numbers are actual text), you only need to use the first dimension to access the data.

If it is related to numbers 1D array can be used (which is recommended).


Re: Array print - bgedition - 17.05.2016

Okay, perhaps you do not understood me. I will make it 1D but how can I print the whole array like in PHP?

EDIT: Should I make a loop to loop thru all of the array data?


Re: Array print - Konstantinos - 17.05.2016

pawn Код:
new b[] = {'1', '2', '3', '4'};
nothing is stopping you from doing:
pawn Код:
print(b);
which prints "1234". That's how strings work anyway.


Re: Array print - bgedition - 17.05.2016

Okay this works with integers but how about characters?

Код:
	//This below only prints "Zero"
	new Array = {"Zero", "One", "Two", "Three"};
	print(Array);
there:



Re: Array print - Konstantinos - 17.05.2016

That's a set of strings so you need to access each one from the 1st dimension.

Quote:
Originally Posted by bgedition
Посмотреть сообщение
EDIT: Should I make a loop to loop thru all of the array data?
I somehow missed that part. Yes, use a loop.


Re: Array print - bgedition - 17.05.2016

Okay thank you for your time