I have an Array I want to rewrite with many elements as the value of any key
Array
(
[cap] => 3
[shirt] => 2
[tatuaggio] => 1
[badge] => 2
)
and I want this output
Array
(
cap,cap,cap,shirt,shirt,tatuaggio,badge,badge
)
so I can have all data and split the array in many array with 7 elements When I have the loop
foreach ($array_caselle as $k => $v) {
//with this I have access to all key, but how can I do an other foreach for the value of each key?
}
Use a nested
for
loop.or use
array_fill()
: