[Resolved] Need PHP help for sorting an array
As I’m not very strong on PHP, I thought I’d ask here for some help.
I’m trying to sort out a way of displaying my links from one category, but in three columns. As this list is going to be expanding I need to code this in a future proof way.
I’m thinking that the best way to do this would be to use the get_bookmarks function to return an array of my bookmarks. I could then analyse the array, work out how many bookmarks are in it, divide by 3, and then display that number of bookmarks in each column, being careful to avoid any duplication.
Problem is I haven’t the first notion of how I would go about doing this!
Here’s my english/code demo:
<?php $array = get_bookmarks('category=1'); $columnlength = $array/3; ?> <div class="col1"> wp_list_bookmarks('limit=$columnlength'); </div> <!-- As there's no offset function so I don't know what to do for columns 2 and 3 --> <div class="col2"> wp_list_bookmarks('limit=$columnlength'); </div> <div class="col3"> wp_list_bookmarks('limit=$columnlength'); </div>
I am assuming that I’m going to need to do something a little more sophisticated and outside of the get_bookmarks/wp_list_bookmarks functions..?
- The topic ‘[Resolved] Need PHP help for sorting an array’ is closed to new replies.