Jump to content

multiple blockquote to single textformat


emehrkay

Recommended Posts

i am using a wysiwyg text editor to input text to a db that flash displays. flash sucks. anyway, flash doesnt like blockqoutes and perfers textformat with an attribute of blockindent. flash still sucks

 

i want to go from

<blockquote><blockquote><blockquote>text</blockquote></blockquote></blockquote>

 

to

<textformat blockindent="34">text</textformat>

 

where 3 blockquotes = 34, 2 or 1 = 20

 

flash sucks and i have no idea where to start.

 

thanks for your help

 

Link to comment
https://forums.phpfreaks.com/topic/60560-multiple-blockquote-to-single-textformat/
Share on other sites

It sounds like berating Flash is just as important as getting help.... Try this:

 

<pre>
<?php

$str = <<<STR
<b>Test</b>	
<blockquote>one</blockquote>
<blockquote><blockquote><i>two</i></blockquote></blockquote>
<blockquote><blockquote><blockquote>three</blockquote></blockquote></blockquote>
<blockquote><blockquote><blockquote><blockquote>four</blockquote></blockquote></blockquote></blockquote>
STR;

$blockindent = array(20, 20, 34);

function my_print_r($array) {
	foreach ($array as $key => &$value) {
		$value = htmlspecialchars($value);
	}
	print_r($array);
}

$pieces = preg_split('#(?:<blockquote>)+(.*?)(?!</blockquote>)#', $str, -1 , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
my_print_r($pieces);

foreach ($pieces as &$piece) {
	if (strpos($piece, '</blockquote>') == FALSE) {
		continue;
	}
	$piece = preg_replace('#</blockquote>#', '', $piece, -1, $blockquotes);
	if ($indent = $blockindent[$blockquotes-1]) {
		$piece = '<textformat blockindent="' . $indent . '">' . $piece . '</textformat>';
	}
	else {
		echo "Error: No blockindent exists for $blockquotes blockquotes.<br>";
	}
}
my_print_r($pieces);
?>
</pre>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.