Código:
function decode_oculto($str)
{
$str = preg_replace_callback("/\[oculto\]\n(.*(\n)*)\n\[\/oculto\]/i", array($this, "create_oculto"),$str);
return $str;
}
Y la función que lo sustituye. Pero ya digo, el problema está en el replace, que no sé las expresiones que tengo que poner.
Código:
function create_oculto($matches)
{
$oculto="<div><div class='pre-spoiler'>";
$oculto.="<input value=\"Mostrar\" style=\"margin: 0px; padding: 0px; width: 80px; height: 18px; font-size: 10px; float: left;\" onclick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';this.innerText = ''; this.value = 'Ocultar'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.value = 'Mostrar';}\" type=\"button\"> Texto oculto";
$oculto.="</div>";
$oculto.="<div><div class='spoiler' style='display: none;'>".$matches['1']."</div>";
$oculto.="</div></div>";
return $oculto;
}