 <p>the whole thing can be changed to something like this for better readability...</p> <pre><code>&lt;?php $myradiooptions = array( "grid1" =&gt; "Grid View (default)", "list1" =&gt; "List View (1 column)", "list2" =&gt; "List View (2 column)" ); $value = array( "name" =&gt; "Category Layout", "desc" =&gt; "description goes here", "id" =&gt; "my_category_layout", "type" =&gt; "radio", "options" =&gt; $myradiooptions ); foreach($value as $key =&gt; $val) { $formHTML = "&lt;label class='left' for='{$value['id']}'&gt;".$value['name']."&lt;/label&gt;"; if(is_array($val)) { $count = 1; foreach($val as $k =&gt; $v) { $formHTML .= "&lt;input type='radio' name='{$v['id']}' id='$count' value='$v' /&gt;&lt;label style='color:#666; margin:0 20px 0 5px;' for='$count'&gt;$v&lt;/label&gt;"; $count ++; } } $formHTML .= "&lt;label class='description' style='margin-top:-5px;'&gt;".$value['desc']."&lt;/label&gt;"; } //switch, case "radio": ?&gt; &lt;li class="section"&gt; &lt;?php print $formHTML; ?&gt; &lt;/li&gt; </code></pre>