So I have array like this one.
[
'0020098238 - Address 1' => [
'20011045 - 1',
'20011880 - 2',
'20014727 - 3',
'20015506 - 4'
],
'0020011189 - Address 2' => [
'20012490 - 11',
'20018679 - 22',
'20023569 - 33',
'20028843 - 44'
],
'0020102015 - Address 3' => [
'20008315 - 55',
'20008689 - 66',
'20021267 - 77',
'20032518 - 88'
]
]
Now, I want to make foreach or implode or something else and as result get list like this one
- 0020098238 - Address 1
- 20011045 - 1
- 20011880 - 2
- 20014727 - 3
- 20015506 - 4
- 0020011189 - Address 2
- 20012490 - 11
- 20018679 - 22
- 20023569 - 33
- 20028843 - 44
- 0020102015 - Address 3
- 20008315 - 55
- 20008689 - 66
- 20021267 - 77
- 20032518 - 88
I have tried with foreach($array as $key => $val) and than implode $val but it doesnt work propper. I can collect keys but values from array missing.
Thx
Here is what I have tried (nested foreach)
foreach ($user_sap_data as $customer => $destinations) {
echo '<ul>';
echo '<li>' . $customer . '</li>';
foreach ($destinations as $destination) {
echo '<li>' . $destination . '</li>';
}
echo '</ul>';
}
but as result I am getting only key of first foreach (in nested foreach)
It is not the same question like PHP nested array into HTML list because in other question there are key => (key => val, key => val...) but in this example is key => (val, val, val) etc. its similair but not duplicated
ultag. Check this answer