Adding an item to an associative array

后端 未结 5 1381
太阳男子
太阳男子 2020-12-12 20:02
//go through each question
foreach($file_data as $value) {
   //separate the string by pipes and place in variables
   list($category, $question) = explode(\'|\', $v         


        
5条回答
  •  眼角桃花
    2020-12-12 20:32

    I know this is an old question but you can use:

    array_push($data, array($category => $question));
    

    This will push the array onto the end of your current array. Or if you are just trying to add single values to the end of your array, not more arrays then you can use this:

    array_push($data,$question);
    

提交回复
热议问题