Splitting WordPress Content Into Multiple Columns

The post How to Split WordPress Content Into Two or More Columns has come in really handy for a project my co-workers and I have been working on. However, we ran into a problem where it was impossible to get more than $content[0] and $content[1] to work. If there was a third <!–more–> tag, it would be ignored and $content[2] returned nothing (we are using Wordpress 3.0). I noticed that we weren’t the only ones having this problem (the last comment on that post posed the same problem and received no replies). So in an effort to help out others, here is the solution my co-worker came up with:



// split content at the more tag and return an array

function split_content() {
	global $more;
	$more = true;
	$content0 = preg_split('/<span id="more-\\d+"><\\/span>/i', get_the_content('more'));      // first <!--more--> tag gets turned into <span id="more-[number]"></span>
	$content1 = preg_split('/<!--more-->/i', $content0[1]);	// but all the remaining ones are left as <!--more-->
	$content = array_merge(array($content0[0]), $content1);	// so we have this here ugly hack
	
	for($c = 0, $csize = count($content); $c < $csize; $c++) {
		$content[$c] = apply_filters('the_content', $content[$c]);
	}
	return $content;
}


Feedback is welcomed.