function format_quotes($s) { $old_s = ''; while ($old_s != $s) { $old_s = $s; //find first occurrence of [/quote] $close = strpos($s, "[/quote]"); if ($close === false) { return $s; } //find last [quote] before first [/quote] //note that there is no check for correct syntax $open = _strlastpos(substr($s, 0, $close), "[quote"); if ($open === false) { return $s; } $quote = substr($s, $open, $close - $open + 8); //[quote]Text[/quote] $quote = preg_replace("/\\[quote\\]\\s*((\\s|.)+?)\\s*\\[\\/quote\\]\\s*/i", "<p class='sub'><b>Quote:</b></p><table class='main' border='1' cellspacing='0' cellpadding='10'><tr><td style='border: 1px black dotted'>\\1</td></tr></table><br />", $quote); //[quote=Author]Text[/quote] $quote = preg_replace("/\\[quote=(.+?)\\]\\s*((\\s|.)+?)\\s*\\[\\/quote\\]\\s*/i", "<p class='sub'><b>\\1 wrote:</b></p><table class='main' border='1' cellspacing='0' cellpadding='10'><tr><td style='border: 1px black dotted'>\\2</td></tr></table><br />", $quote); $s = substr($s, 0, $open) . $quote . substr($s, $close + 8); } return $s; }
/** * Format quotes * @param string $s * @return string */ function format_quotes($s) { $old_s = ''; while ($old_s != $s) { $old_s = $s; $close = strpos($s, "[/quote]"); if ($close === false) { return $s; } $open = _strlastpos(substr($s, 0, $close), "[quote"); if ($open === false) { return $s; } $quote = substr($s, $open, $close - $open + 8); //[quote]Text[/quote] $quote = preg_replace("/\\[quote\\]\\s*((\\s|.)+?)\\s*\\[\\/quote\\]\\s*/i", "<div class='citation'>\\1</div><br />", $quote); //[quote=Author]Text[/quote] $quote = preg_replace("/\\[quote=(.+?)\\]\\s*((\\s|.)+?)\\s*\\[\\/quote\\]\\s*/i", "<div class='citation'><b>\\1 said</b>: <div class='blockquote'>\\2</div></div><br />", $quote); $s = substr($s, 0, $open) . $quote . substr($s, $close + 8); } return $s; }
function format_quotes($s) { $old_s = ''; while ($old_s != $s) { $old_s = $s; //find first occurrence of [/quote] $close = strpos($s, "[/quote]"); if ($close === false) { return $s; } //find last [quote] before first [/quote] //note that there is no check for correct syntax $open = _strlastpos(substr($s, 0, $close), "[quote"); if ($open === false) { return $s; } $quote = substr($s, $open, $close - $open + 8); //[quote]Text[/quote] $quote = preg_replace("/\\[quote\\]\\s*((\\s|.)+?)\\s*\\[\\/quote\\]\\s*/i", "<div class='citation'>\\1</div><br />", $quote); //[quote=Author]Text[/quote] $quote = preg_replace("/\\[quote=(.+?)\\]\\s*((\\s|.)+?)\\s*\\[\\/quote\\]\\s*/i", "<div class='citation'><b>\\1 said</b>: <div class='blockquote'>\\2</div></div><br />", $quote); $s = substr($s, 0, $open) . $quote . substr($s, $close + 8); } return $s; }