PHP, JSON, AJAX, and Array

0 favourites
  • 8 posts
From the Asset Store
Paypal PHP Supports multiple platforms, Web/html5 Android, IOS. (Including storing transaction data)
  • Hello,

    I have a json from a php file:

    {"c2array":true,"size":[3,1,1],"data":["test1","test2","test3"]}

    My array in c2

    width 3, height 1 and depth 1

    <img src="http://54.214.236.44/json.JPG" border="0" />

    result

    <img src="http://54.214.236.44/json2.JPG" border="0" />

    Help?

  • You're setting the text to the loop's current X value (The cell's X position, not what it contains). You probably want to replace:

    Append"-"&Array.CurX

    with

    Append"-"&Array.CurValue

  • Also, you activate the group, triggering this loop at every tick, so you'll have an infinity of data output. Call a function instead, or deactivate the group after.

  • Also, you activate the group, triggering this loop at every tick, so you'll have an infinity of data output. Call a function instead, or deactivate the group after.

    how? do u have a example?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You're setting the text to the loop's current X value (The cell's X position, not what it contains). You probably want to replace:

    Append"-"&Array.CurX

    with

    Append"-"&Array.CurValue

    same result

  • Also, you activate the group, triggering this loop at every tick, so you'll have an infinity of data output. Call a function instead, or deactivate the group after.

    <img src="http://54.214.236.44/json11.JPG" border="0" />

    result with CurX

    <img src="http://54.214.236.44/json22.JPG" border="0" />

    with CurValue i got

    -t -t -t

    i need "test1" "test2" and "test3"

  • I can't produce a capx right now (computer down), but if I remember well, the JSON for an array in C2 is 3 dimensional in the datas, as the array is. So you would have to load it with :

    {"c2array":true,"size":[3,1,1],"data":[[["test1"]],[["test2"]],[["test3"]]]}

    and not :

    {"c2array":true,"size":[3,1,1],"data":["test1","test2","test3"]}

    witch is consistant with your current result (taking the [0][0] of a string is the first letter)

  • Works

    Thank You!

    Now i will try with

    test1 => value1

    test2 => value2

    test3 => value3

    i have to change my Array in c2 Height = 2?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)