How to nest elements in a render array So, I'm trying to generate some markup using render arrays. I need to create some nested divs. I thought that I could do this by nesting the arrays, as such:

function make_array() {
  $items = port_view_get_block();
  $array['container']['#prefix'] = '&lt;div id = "container"&gt;';
  $array['container']['#suffix'] = '&lt;/div&gt;';
  $array['container']['#markup'] = 'This is inside the container div';
  $array['container']['slider']['#prefix'] = '&lt;div id = "slider"&gt;';
  $array['container']['slider']['#suffix'] = '&lt;/div&gt;';
  $array['container']['slider']['#markup'] = 'This is inside the slider div';
  return $array;
}


This doesn't seem to work. The inner array isn't rendered. 

What is the proper way to get a nested structure using render arrays?
If an element is given #markup, the render process stops searching for nested elements. To accomplish what you need, just create a second child element with no #prefix or #suffix.

function make_array() {
  $items = port_view_get_block();
  $array = array(
    'container' =&gt; array(
      '#prefix' =&gt; '&lt;div id="container"&gt;',
      '#suffix' =&gt; '&lt;/div&gt;',
      'markup' =&gt; array(
        '#markup' =&gt; 'This is inside the container div',
      ),
      'slider' =&gt; array(
        '#prefix' =&gt; '&lt;div id="slider"&gt;',
        '#suffix' =&gt; '&lt;/div&gt;',
        '#markup' =&gt; 'This is inside the slider div',
      ),
    ),
  );
  return $array;
}