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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -