To save on typing out the key name for every single array, I want to be able to build lists like.
$lists = [
['A', 'B', 'C', 'D', 'E'],
['A', 'B', 'C', 'D', 'E'],
['A', 'B', 'C', 'D', 'E'],
];
and then assign the same key names to all them (either before or after)
Key1, Key2, Key3, Key4, Key5
so when they're called, I can do something like:
foreach ($lists as $list) {
showList($list);
}
and then within the showList()
function, I can call the 5 keys by the key name.
The function I have set no problem, but it's assigning the key names that I'm not sure how to do.
From comment under @Barmar's answer:
I get the following error..
Warning: array_combine() [function.array-combine]: Both parameters should have an equal number of elements
In
$lists
, the element count does go up to 29. That's the only thing I can think of that doesn't match, but I thought it would see 5 keys for 5 values in each of the 29 arrays within$lists.
Try this :
Result: