note 98567 deleted from function.json-decode by googleguy

From: Date: Fri, 30 Nov 2012 05:43:36 +0000
Subject: note 98567 deleted from function.json-decode by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192218@lists.php.net to get a copy of this message
Note Submitter: steveo at crecon dot com ---- I was getting an array like: Array ( [COLUMNS] => Array ( [0] => ID [1] => FIRST [2] => LAST ) [DATA] => Array ( [0] => Array ( [0] => 10 [1] => Mary [2] => Smith ) [1] => Array ( [0] => 11 [1] => Joe [2] => Black ) [2] => Array ( [0] => 12 [1] => Tom [2] => Green ) [3] => Array . . . With lots more columns and data from a json_decode call to a Cold Fusion .cfc which returned a database query. This is easy to turn into a nice associative array with the following code: <?php foreach ($results['DATA'] as $rowcount => $row){ foreach ($row as $colcount => $col){ $lines[$rowcount][$results['COLUMNS'][$colcount]]=$col; } } ?> to get: Array ( [0] => Array ( [ID] => 10 [FIRST] => Mary [LAST] => Smith ) [1] => Array ( [ID] => 11 [FIRST] => Joe [LAST] => Black ) . . . etc. I hope this helps someone.

« previous php.notes (#192218) next »