Php – Associative array with multiple values in php

arraysphp

can we have associative array with multiple values for same key in php ?

example:-

array[key1] => value1, value2, value3
array[key2] => value4, value5, value6

Best Solution

Yes:

array[key1] => array(value1, value2, value3)
array[key2] => array(value4, value5, value6)

You can also have associative arrays in an associative array:

array[key1] => array(key => value1, key => value2, key => value3)
array[key2] => array(key => value4, key => value5, key => value6)