cakephp - Cake php multidimensional array -


i have array coming join query when debug found output. here code in controller

$agetfeaturegigs = $this->gigs->getfeaturegigs(); $this->set('agetfeaturegigs', $agetfeaturegigs);  $yourvalue='7'; foreach($agetfeaturegigs $key => $val) {     $agetfeaturegigs[$key]['gigs']['manual'] = $yourvalue; } 

output

array(     (int) 0 => array(         'usersjoin' => array(             'action' => 'yes'         ),         'gigs' => array(             'id' => '2',             'username' => 'nmodi',             'category' => 'creativity  & designing',             'subcategory' => 'logo design',             'picture' => 'banner_logo1.jpg',             'video' => '',             'title' => 'i design 2 awesome logo design in 48 hours',             'delivery' => '24 hrs',             'workinghrs' => '3',             'feature' => 'yes',             'action' => 'yes',             'del' => 'no'         )     ),     (int) 1 => array(         'usersjoin' => array(             'action' => 'yes'         ),         'gigs' => array(             'id' => '1',             'username' => 'ptailor',             'category' => 'creativity  & designing',             'subcategory' => 'logo design',             'picture' => '128.jpg',             'video' => 'https://www.youtube.com/watch?v=ktcf5tyar-o&feature=inp-gs-iol-07-47',             'title' => 'i proofread , edit document proofread , edit document',             'delivery' => '12 hrs',             'workinghrs' => '2',             'feature' => 'yes',             'action' => 'yes',             'del' => 'no'         )     ) ) 

but need add field rating manual values bellow del inside gigs array. please me solve this.

if need insert same value each gigs array in data can use cakephp's hash utility this:-

hash::($data, '{n}.gigs.rating', $value); 

where $data array , $value value want insert associative key of rating.

hash work both cakephp 2 , 3. remember in cake 3 need handle namespacing above can done as:-

cake\utility\hash::($data, '{n}.gigs.rating', $value); 

if need insert different values need loop on array:-

foreach ($data &$item) {     $item['gigs']['rating'] = $value; } 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -