alegalviz's Recent Forum Activity

  • I know it is an old post, but looking for an answer I came here.

    I could resolve it, the Json format its a must.

    My php to fill a 2 dimension array:

    $data is an asociative array, each row has an array with 3 key => value data: id:number, name:string, points:number. It's for a ranking.

        $rows = count($data);
        $cols = 3;
        $depth = 1;
        if (!empty($data)) {
            $datos = '{"c2array":true,"size":[' . $rows . ',' . $cols . ',' . $depth  . '],"data":[';
    
            foreach ($data as $fila) {
                $datos .= "[";
                foreach ($fila as $key => $value) {
                    $datos .= '["' . $value . '"],';
                }
                $datos = rtrim($datos, ",");
                $datos .= "],";
            }
            $datos = rtrim($datos, ",");
            $datos .= "]}";
        }[/code:280juy0m]
    
    [code:280juy0m]{
        "c2array":true,
        "size":[3,3,1],
        "data":
        [
        [
            ["4"],["mark"],["299"]
        ],[
            ["2"],["steve"],["23"]
        ],[
            ["3"],["bill"],["3"]
        ]
        ]
     }[/code:280juy0m]
    
    Then, you can access all data in array.
    Name: arrRanking.At(X,1,0)
    Points: arrRanking.At(X,2,0)
    
    I tried to loop filling 10 text boxes but I don't know how... yet jiji.   
    
    UPDATE: Now I could fill the text boxes in a loop.
    
    You only need a instance variable in the text box.
    
    [img="https://4.bp.blogspot.com/-95R8o9WE-Vw/Vi99up6hstI/AAAAAAAAA24/Wh3dYTs4rqY/s1600/json%2Bconstruct2.PNG"]
    
    Alek
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
alegalviz's avatar

alegalviz

Member since 10 Sep, 2015

None one is following alegalviz yet!

Connect with alegalviz

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies