php - How to merge array in same indexing in codeigniter -


i have merge 2 array , got following result.

array (     [0] => year     [1] => month     [2] => array         (             [id_question] => 88             [question] => question no. 1             [question_type] => 3             [answer_type] => option             [question_level] => district             [addedon] => 2017-07-23 19:15:26         )      [3] => array         (             [id_question] => 87             [question] => question no. 2             [question_type] => 3             [answer_type] => text             [question_level] => district             [addedon] => 2017-07-16 00:45:19         ) 

now want same index , remove except question following

array     (         [0] => year         [1] => month         [2] => question no. 1         [3] => question no. 2      ) 

please me. in advance

you can try way, not tested

$expected_array=[]; foreach($your_2d_array $k=>$v){     if(is_array($v){      $expected_array[$k] = $v['question'];     }else{      $expected_array[$k] =$v;    } }  echo "<pre>"; print_r($expected_array); echo "</pre>"; 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -