1) ? $bits : array('', $bits[0]); $bits = preg_split("/\(:colend:\)/", $m[2]); // when splitting, be carefull post can be empty list($rest, $post) = (count($bits) > 1) ? $bits : array($bits[0],''); $bits =explode("(:column:)",$rest); $num_columns=count($bits)+1; $width=intval(100/$num_columns); $cell_sep="(:cell valign=top width=" . $width . "%:)"; $cel_head="(:cellnr valign=top width=" . $width . "%:)"; if (count($bits) > 1) { // $two=$bits[0]; $two=implode($cell_sep, $bits); } else { $two=$rest; } return<<