Building JSON data using PHP -



Building JSON data using PHP -

i produce next json output using php

{ "dataid": "an optional sourcetable identifier", "columns": [ { "colvalue": "status", "coltext": "status", "header": "status", "sortbycol": "status", "groupbyrank": null, "pivot": true, "result": false }, { "colvalue": "priority", "coltext": "priority", "header": "priority", "sortbycol": "priority", "dataid": "an optional id.", "groupbyrank": 4, "pivot": false, "result": false }, { "colvalue": "team", "coltext": "team", "header": "team", "sortbycol": false, "dataid": "an optional id.", "groupbyrank": 1, "pivot": false, "result": false }, { "colvalue": "module", "coltext": "module", "header": "module", "sortbycol": "module", "dataid": "an optional id.", "groupbyrank": 2, "pivot": false, "result": false }, { "colvalue": "sla", "coltext": "sla", "header": "sla", "sortbycol": "sla", "dataid": "an optional id.", "groupbyrank": 3, "pivot": false, "result": false }, { "colvalue": "score", "coltext": "score", "header": "score", "sortbycol": "score", "groupbyrank": null, "pivot": false, "result": true } ], "rows": [ { "team": "technical", "module": "basis", "sla": "critical", "priority": "high", "status": "in progress", "score": "1", "score2": "18.27" }, { "team": "technical", "module": "basis", "sla": "critical", "priority": "high", "status": "in progress", "score": "1", "score2": "18.27" }, **** more entries iterated based on sql row *** ]

}

however stuck on how combine array hardcoded , dynamic info (taken mysql row).

the next php code generate column , dataid static

$test = array( "dataid" => 'an optional sourcetable identifier', "columns" => array( array( 'colvalue' => 'status', 'coltext' =>'status', 'header' =>'status', 'sortbycol' => 'status', 'groupbyrank' => null, 'pivot' => true, 'result' => false ), array( 'colvalue' => 'priority', 'coltext' => 'priority', 'header' => 'priority', 'sortbycol' => 'priority', 'dataid' => 'an optional id.', 'groupbyrank' => 4, 'pivot' => false, 'result' => false ), ) );

what stuck how combine row data? can help me this.

thanks

you can ammend existing arrays using new key:

$test['rows'] = $yourrowdataasarray;

php json

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -