创建一个关联数组,其中包含多个值到php中的一个键[关闭]

I want to dynamically create an associative array where we can assign multiple values to one key in php. That is each key behaves itself as an array. Eg

$array=[$one->'1','2','3';
    $two->'4','5';
    $three->'1']

I will dynamically receive values for every key in a loop, so i cannot initialise the entire array statically.Please give the entire php code for this.

Why dont you create an array of arrays?

$array = array();
$array[1] = array();
$array[2] = array();
$array[3] = array();
array_push($array[1],1);
array_push($array[1],2);
array_push($array[1],3);
array_push($array[2],4);
array_push($array[2],5);
array_push($array[3],6);

You will be able to add as many as you like, and create new fields when needed. In general though you will have to give you variable names more meaningful than just $array :)