Revision: 4233
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 10, 2007 18:42 by inkdeep
Initial Code
function array_to_json_string($arraydata) { $output = ""; $output .= "{"; foreach($arraydata as $key=>$val){ if (is_array($val)) { $output .= "\"".$key."\" : [{"; foreach($val as $subkey=>$subval){ $output .= "\"".$subkey."\" : \"".$subval."\","; } $output .= "}],"; } else { $output .= "\"".$key."\" : \"".$val."\","; } } $output .= "}"; return $output; }
Initial URL
Initial Description
SEE http://json.org/ for PHP JSON Libraries. grunt knuckle drag brute force ugly escapes for quotes make a php array a json string Produces trailing commas which some Javascript Librarys can't deal with.* _*NOOB NOTE [a comma is added at the end of each array key/value set]_
Initial Title
PHP Array To JSON String
Initial Tags
php, array, json
Initial Language
JavaScript