I'm pretty new to PHP and am looking into using array_chunk() to split an array into three parts to display it as a three column list. Let's say I have an array like this
$input_array = array('a', 'b', 'c', 'd', 'e', 'f');
$chunks = array_chunk($input_array, 3, true));
and I want to output something like:
<div class="left">
<ul>
<li>a</li>
<li>b</li>
</ul>
</div>
<div class="middle">
<ul>
<li>c</li>
<li>d</li>
</ul>
</div>
<div class="right">
<ul>
<li>e</li>
<li>f</li>
</ul>
</div>
I've seen some really helpful examples on here but none that show how to foreach loop each chunk of the original array to place where you need within your html/css.
Is this a job for array_slice? But what if my array is dynamically populated and I don't know how big it will be at a given time?
Thanks!