PHP's str_replace

Soldato
Joined
10 Dec 2003
Posts
6,348
I am modifying my personal blog at the moment, which is based on Wordpress. My first problem was removing all indentations and whitespace, which I did fine, as so:

Code:
	<?php ob_start("posts"); ?>

		//Content
						
	<?php ob_end_flush(); ?>

The 'posts' function being:

Code:
<?php

	function posts($source) {

		$find = array(
			"\n",
			"\t"
		);

		$replace = array(
			"",
			""
		);

	return str_replace($find, $replace, $source);

	}
	
?>

The problem is, if I wish to place code into a post, using the <pre> tags, all the changes of that function apply to it; removing neccersary indentations and such, which I don't want.

How can I make it so the function ignores everything inbetween the <pre> tags, but applies itself to everything else?
 
I can't figure it out thus far.

The problem is that the function, at some point, needs to remove all indentation. I'm going to try outputting content between those tags, as a separate variable. Hmm.
 
Back
Top Bottom