javascript - generating multidimentional object with array -


i generating object this:

console snapshot

as can see education array inside object, want degree_1 , major_1 , values in same object.

this how want education array: enter image description here

one other thing: when var_dump in php fine arrays , everything. javascript gets second image above- object of object when array..

public function show($id) {     $tmp = array();     $post = array();     $postinfo = post::find($id);     $params =  db::select( db::raw("select param.*, sys_param_values.*,param_value.*,type_post.*,                                        param.name paramname,                                         doc_param.name docparamname                                         param                                        left join doc_param on param.doc_param_id = doc_param.id                                        left join sys_param_values on param.id = sys_param_values.param_id                                        left join param_value on sys_param_values.value_ref = param_value.id                                        left join type_post on sys_param_values.ref_id = type_post.id type_post.id = ".$id));      $ismultiple = false;     $post['postinfo'] = $postinfo['original'];     foreach($params $k=>$v) {          $iteration    = $v->iteration;         $docparamname = $v->docparamname;         $paramname    = $v->paramname;          if($v->value_ref == null) {             $value = $v->value_short;         } else {             $value = $v->value;         }          if($iteration) {              $post[$docparamname][$iteration][$paramname] = $value;             // need return education array not object             // $post[$docparamname][] = array($paramname=>$value) ;          }elseif(!$iteration) {             $post[$docparamname][$paramname] = $value;         }     }         return response::json($post); } 

make first element education 0, 1, that's why json_encode parsing object.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -