将列表拆分为多个列,留下尾随</ li>标记

I can't figure out why the last column (4) in this leaves a </li> tag at the end.

<?php 
$pageArray = explode("</li>",wp_list_pages('title_li=&echo=0&depth=-1&sort_column=post_name&exclude=82,9,13'));
$pageCount = count($pageArray) ;
$pageColumns = round($pageCount / 4);
$twoColumns = round($pageColumns + $pageColumns);
$threeColumns = round($pageColumns + $pageColumns + $pageColumns - 1);
$fourColumns = round($pageColumns + $pageColumns + $pageColumns + $pageColumns - 2);        
    for ($i=0;$i<$pageCount;$i++) {
    if ($i<$pageColumns){
        $col1 = $col1.''.$pageArray[$i].'</li>';
    }
        elseif ($i<$twoColumns) {
        $col2 = $col2.''.$pageArray[$i].'</li>';
    }  
    elseif ($i<=$threeColumns) {
        $col3 = $col3.''.$pageArray[$i].'</li>';
    }  
     elseif ($i<=$fourColumns) {
        $col4 = $col4.''.$pageArray[$i].'</li>';
    }  
 };
?>

<ul>
  <?php echo $col1; ?>
</ul>
<ul>
  <?php echo $col2; ?>
</ul>
<ul>
  <?php echo $col3; ?>
</ul>
<ul>
  <?php echo $col4; ?>
</ul>

What I get in the last list is:

<ul>    
    <li class="page_item page-item-23"><a href="http://google.com">link1</a></li>
    <li class="page_item page-item-27"><a href="http://google.com">link2</a></li>

    </li> <--the problem
</ul>

Any ideas?

I figured it out.

Simply change this:

for ($i=0;$i<$pageCount;$i++) {

to this:

for ($i=0;$i<$pageCount-1;$i++) {

and that removed the trailing </li> tag