How do I fetch string value from an array?

Get help using Construct 2

Post » Mon Mar 23, 2015 9:50 am

I believe it's a trivial problem but I really can't find the answer anywhere by google nor this forum, so I'm making a post (sorry if this is redundant but couldn't find it).

I'm loading data from server (PHP) to an array in C2. Data goes encoded with JSON as 2d array with looks more or less like that:
Code: Select all
{"c2array":true,"size":[5,3,null],"data":[["1","One-1","One-2"],["2","Oj","a"],["3","Mawy","a"],["4","Dake sw","a"],["5","Rowa","ezao celtah, myce, grah"]]}


I tried also with size [5,3,1] and [5,3,0]. My problem here is that when I do foreach (XY) loop then for the indexes where I would expect a string as a value, I recieve a single character. For example myArray.at(0,1) returns "O" instead of whole string "One-1". Same thing happens when I use CurValue just to debug data.

Any help please?
Image
B
27
S
14
G
54
Posts: 853
Reputation: 31,110

Post » Mon Mar 23, 2015 12:02 pm

Hi,

I think it sould be :
{"c2array":true,"size":[5,3,1],"data":[[["1"],["One-1"],["One-2"]],[["2"],["Oj"],["a"]],[["3"],["Mawy"],["a"]],[["4"],["Dake sw"],["a"]],[["5"],["Rowa"],["ezao celtah"],["myce"], ["grah"]]]}
B
14
S
4
G
2
Posts: 190
Reputation: 3,938

Post » Mon Mar 23, 2015 12:13 pm

beufreecasse wrote:I think it sould be :
{"c2array":true,"size":[5,3,1],"data":[[["1"],["One-1"],["One-2"]],[["2"],["Oj"],["a"]],[["3"],["Mawy"],["a"]],[["4"],["Dake sw"],["a"]],[["5"],["Rowa"],["ezao celtah"],["myce"], ["grah"]]]}


Hi @beufreecasse!
That's the charm I was looking for! Thank you very much I stucked with this second day already and you saved me! :)
Image
B
27
S
14
G
54
Posts: 853
Reputation: 31,110

Post » Mon Mar 23, 2015 6:31 pm

Glad to help :)
B
14
S
4
G
2
Posts: 190
Reputation: 3,938


Return to How do I....?

Who is online

Users browsing this forum: jdevone, Lancifer and 6 guests