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
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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.