Given:
I don't understand why it produces:Code:function table($array) { foreach ($array as $x) { if (is_array($x)) { table($x); } else echo "<div class=\"table_cell\">$x</div>\n"; } echo "<div class=\"clear\"></div>\n"; } table( array( array("1", "2"), array("3", "4") ) );
I've tried to run through this recursive function mentally but I just can't seem to understand why it produces an extra div.Code:<div class="table_cell">1</div> <div class="table_cell">2</div> <div class="clear"></div> <div class="table_cell">3</div> <div class="table_cell">4</div> <div class="clear"></div> <div class="clear"></div>
What I'm trying to do, is write:at the end of each sub-array.Code:<div class="clear"></div>
Any thoughts anyone?



Reply With Quote


Bookmarks