php - Not Sequencial Array to JSON (Keys are string) -
i'm trying create custom array, custom array keys. until here works well.
foreach ($results $value){ // $value['month'] string (varchar) $return[$value['month']]['working'] = $value['work_job']; }
but, when return json, i'm getting follow situation.
"jobs": { // here need [ instead of {, how can fix it? "2": { "working": "1" }, "5": { "working": "4" }, "6": { "working": "3" } } $return = array("jobs" => $return, "testing" => 'testing');
tks
there's little concept issue in this.
in php, hashes or dictionaries represented arrays, not in other languages.
if array composed syntax
$array['key'] = $value;
it interpreted json encoder object. understand $array object, 'key' property of $array , $value value of property, being encoded this.
array = { key: value }
Comments
Post a Comment