Is there a way to add the ul label to the output?

 <?php
    
      $content = "";
      
      $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">' . "\
";
      for ($i=0;$i<sizeof($box_categories_array);$i++) {
        switch(true) {
    // to make a specific category stand out define a new class in the stylesheet example: A.category-holiday
    // uncomment the select below and set the cPath=3 to the cPath= your_categories_id
    // many variations of this can be done
    //      case ($box_categories_array[$i]['path'] == 'cPath=3'):
    //        $new_style = 'category-holiday';
    //        break;
          case ($box_categories_array[$i]['top'] == 'true'):
            $new_style = 'category-top';
            break;
          case ($box_categories_array[$i]['has_sub_cat']):
            $new_style = 'category-subs';
            break;
          default:
            $new_style = 'category-products';
          }
         if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
            // skip if this is for the document box (==3)
          } else {
          $content .= '<li class="' . $new_style . '"><a  href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
    
          if ($box_categories_array[$i]['current']) {
            if ($box_categories_array[$i]['has_sub_cat']) {
              $content .= '<span class="category-subs-parent">' . $box_categories_array[$i]['name'] . '</span>';
            } else {
              $content .= '<span class="category-subs-selected">' . $box_categories_array[$i]['name'] . '</span>';
            }
          } else {
            $content .= $box_categories_array[$i]['name'];
          }
    
          if ($box_categories_array[$i]['has_sub_cat']) {
            $content .= CATEGORIES_SEPARATOR;
          }
          $content .= '</a></li>';
    
          if (SHOW_COUNTS == 'true') {
            if ((CATEGORIES_COUNT_ZERO == '1' and $box_categories_array[$i]['count'] == 0) or $box_categories_array[$i]['count'] >= 1) {
              $content .= CATEGORIES_COUNT_PREFIX . $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX;
            }
          }
    
          $content .=  "\
";
        }
      }

the above html output like this: http://i.stack.imgur.com/Ltvjp.jpg

Now, I want to add some ul label into the output. Namely, when it’s category-top and have sub category. I want to make the output like this.

 <li class="category-top"> <a href="#">main category</a>
    <ul>
    <li class="category-topb"><a href="#">sub category</a></li>
    <li class="category-topb"><a href="#">sub category</a></li>
    <li class="category-topb"><a href="#">sub category</a></li>
    </ul>
    </li>

When it doesn’t have sub category the output is like this

 `<li class="category-top"> <a href="#">...</a></li>`.

How to add the ul label?
Thank you!
print_r() of the $box_categories_array

    Array
(
    [0] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=1
            [name] =&gt; Hardware
            [has_sub_cat] =&gt; 1
        )

    [1] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=1_17
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;CDROM Drives
        )

    [2] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=1_4
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Graphics Cards
        )

    [3] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=1_8
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Keyboards
        )

    [4] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=1_16
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Memory
        )

    [5] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=1_9
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Mice
        )

    [6] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=1_6
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Monitors
        )

    [7] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=1_5
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Printers
        )

    [8] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=1_7
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Speakers
        )

    [9] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=2
            [name] =&gt; Software
            [has_sub_cat] =&gt; 1
        )

    [10] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=2_19
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Action
        )

    [11] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=2_18
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Simulation
        )

    [12] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=2_20
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Strategy
        )

    [13] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=3
            [name] =&gt; DVD Movies
            [has_sub_cat] =&gt; 1
        )

    [14] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=3_10
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Action
        )

    [15] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=3_13
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Cartoons
        )

    [16] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=3_12
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Comedy
        )

    [17] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=3_15
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Drama
        )

    [18] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=3_11
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Science Fiction
        )

    [19] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=3_14
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Thriller
        )

    [20] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=21
            [name] =&gt; Gift Certificates
        )

    [21] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=22
            [name] =&gt; Big Linked
        )

    [22] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=23
            [name] =&gt; Test Examples
        )

    [23] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=24
            [name] =&gt; Free Call Stuff
        )

    [24] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=33
            [name] =&gt; A Top Level Cat
            [has_sub_cat] =&gt; 1
        )

    [25] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=33_34
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;SubLevel 2 A
            [has_sub_cat] =&gt; 1
        )

    [26] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=33_34_40
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sub Sub Cat 2A1
        )

    [27] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=33_34_43
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sub Sub Cat 2A2
        )

    [28] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=33_35
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;SubLevel 2 B
            [has_sub_cat] =&gt; 1
        )

    [29] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=33_35_37
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sub Sub Cat 2B1
        )

    [30] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=33_35_38
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sub Sub Cat 2B2
        )

    [31] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=33_35_39
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sub Sub Cat 2B3
        )

    [32] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=33_36
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;SubLevel 2 C
            [has_sub_cat] =&gt; 1
        )

    [33] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=33_36_41
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sub Sub Cat 2C1
        )

    [34] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=33_36_44
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sub Sub Cat 2C2
        )

    [35] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=33_36_42
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sub Sub Cat 2C3
        )

    [36] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=48
            [name] =&gt; Sale Percentage
            [has_sub_cat] =&gt; 1
        )

    [37] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=48_45
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;10% off
        )

    [38] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=48_47
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;10% off Attrib
        )

    [39] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=48_31
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;10% off Skip
        )

    [40] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=48_32
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;10% off Price
        )

    [41] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=49
            [name] =&gt; Sale Deduction
            [has_sub_cat] =&gt; 1
        )

    [42] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=49_27
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;$5.00 off
        )

    [43] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=49_52
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;$5.00 off Skip
        )

    [44] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=50
            [name] =&gt; Sale New Price
            [has_sub_cat] =&gt; 1
        )

    [45] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=50_46
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Set $100
        )

    [46] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=50_51
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Set $100 Skip
        )

    [47] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=53
            [name] =&gt; Big Unlinked
        )

    [48] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=54
            [name] =&gt; New v1.2
            [has_sub_cat] =&gt; 1
        )

    [49] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=54_56
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Attributes
        )

    [50] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=54_55
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Discount Qty
        )

    [51] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=54_60
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Downloads
        )

    [52] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=54_57
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Text Pricing
        )

    [53] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=54_61
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Real
        )

    [54] =&gt; Array
        (
            [top] =&gt; false
            [path] =&gt; cPath=54_58
            [name] =&gt; &nbsp;&nbsp;&nbsp;&nbsp;Real Sale
        )

    [55] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=62
            [name] =&gt; Music
        )

    [56] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=63
            [name] =&gt; Documents
        )

    [57] =&gt; Array
        (
            [top] =&gt; true
            [path] =&gt; cPath=64
            [name] =&gt; Mixed Product Types
        )

)

print_r() of the $box_categories_array

You might think that was helpful, but it means anyone wanting to help you has to re-write that all out as a proper PHP array first.

Show us the result of


echo var_export($box_categories_array, 1);

//example
$arr = array('big','bad','wolf');
echo var_export($arr, 1);

// gives
array (
  0 => 'big',
  1 => 'bad',
  2 => 'wolf',
)

…and you might get some more help.

Also, reduce down the size of the demo array a little – and show us exactly what you would like to see when that demo array is done – that way there is less confusion.

In the first case, always keep your example as simple as possible, only show the nub of the problem you are facing.

Add complexity when you understand any replies you may get - try and keep the majority of the html out of the way - add it later.

e.g.


I want :

<ul>
<li>[a value here]</li>
<li>[a value here]
  <ul>
    <li>[a value here]</li> 
    <li>[a value here]</li>
  </ul>
</li>
<li>[a value here]</li>
</ul>