Hi,
I am working on getting a function working which is supposed to find lists in user inputted text, and replace those with HTML list tags.
Userdefined lists:
[lijst]
blablabla
blablablablaaa
[/lijst]
which is supposed to become
<ul>
<li> blablabla</li>
<li> blablablablaa</li>
</ul>
The function below works, but only if just one list is present, which may have a nested list. How do I convert this into a function which will match all lists in the inpyut text? Any ideas?
function createlist($instring) //Lijsten herkend door: [lijst][/lijst] tags en * voor elk element
{
$pattern = "'(\<br \/>|<br>){0,}\s*\[lijst]\s{0,}\*(.*?)\[/lijst\]'si";
$pattern2 = "'\[lijst]\s{0,}</li>(.*?)\[/lijst\]'si";
$pattern3 = "'(\<br>|\<br \/>)\s*(<\/li>)'";
$text = preg_replace($pattern, "<ul><li>\\2</li></ul>", $instring);
$text = str_replace('*', '</li><li>', $text);
$text = preg_replace($pattern2, "</li><ul>\\1</li></ul>", $text);
$text = preg_replace($pattern3, "</li>", $text);
return $text;
}