尝试创建关联数组但不断获取数字

Trying to create associative array but keep getting numeric

我正在尝试创建这样的关联数组

while($row = $result1->fetch_assoc()) {

        $user = $row['first_name'] ."_" . $row['last_name'];
        $userholder[$user] = $row['choice'];
        $event = $row['event_name'] . "_" . $row['event_location'] . "_" . $row['even_date'];
        $consolidateEvents[$event] = $userholder;
    }

但我的 $consolidateEvents 数组是数字的。我看不出我做错了什么。为什么我没有将 $event 作为数组的键?

尝试使用此代码更正您的输出,

function custom_function($input_array){
    $output_array = array();
    foreach ($input_array as $key => $value) {
        foreach ($v as $k => $v) {
            $output_array[$key][$k] = $v;
        }
    }
    return $output_array;
}

试一试,这会奏效