Stack Exchange
Adapting PHP code to split up a list into approximately equal comuns
I have existing PHP code to list product categories as a list of links:
    <?php // as per https://phptechnologytutorials.wordpress.com/2015/11/07/get-
list-of-all-woocommerce-categories/
    $orderby = 'name';
    $order = 'asc';
    $hide_empty = false;
    $excluded = '32';
    $cat_args = array(
        'orderby'    => $orderby,
        'order'      => $order,
        'hide_empty' => $hide_empty,
        'exclude'    => $excluded,
    );

    $product_categories = get_terms( 'product_cat', $cat_args );

    if( !empty($product_categories) ){
        echo '<ul class="linked-product-category-list">';
        foreach ($product_categories as $key => $category) {
            echo '<li>';
            echo '<a href="'.get_term_link($category).'" >';
            echo $category->name;
            echo '</a>';
            echo '</li>';
        }
        echo '</ul>';
    }
    ?>

I found another Stack Overflow solution which demonstrates how to do what I want to achieve - to arrange list of items into 4 equally populated columns.
However, I'm new to PHP and I don't know how to adapt the solution into my own code above.  Please help me to adapt my code above using the principles of the solution below to split up my list into columns.
<?php
$col = 3;
$projects = array_chunk($projects, ceil(count($projects) / $col));

foreach ($projects as $i => $project_chunk)
{
    echo "<ul class='pcol{$i+1}'>";
    foreach ($project_chunk as $project)
        {
        echo "<li>{$project->name}</li>";
    };
    echo "</ul>";
}; ?>


If it is a presentation thing, you should probably do it in css / html instead of php. Makes it easier to adapt to different screen sizes as well.

I was thinking of that - the problem is with CSS is that multi-column features are only available in CSS3, are vendor-specific, and not supported in older browsers.  In addition, I want to list to run in alphabetical order downwards, not inline-style across, and you can't split the list as such, using traditional CSS.

How far back do you need to go? CSS columns is pretty well supported: https://caniuse.com/#search=Multiple%20column%20layout

tbh I don't even want to think about support - I want to be able to go about my business without ever having to worry about it.  A good website should not be held ransom to any uncertainties, even a little.  I know so little about my visitor demographics and it's important that I catch as many visitors as I can.  But thank you, I'll consider it as a last resort.  Not to mention catching all the vendor CSS variations to progressive features as well.

I think you'll catch more visitors worrying about the mobile presentation than you will do worrying about old browsers :-)

Yes, mobile-friendly design is a top priority.  But while it's not an either-or choice, I'd rather have both mobile friendliness and universal compatibility!  :)
