fil79 Posted January 8, 2010 at 05:32 PM Report Share #304844 Posted January 8, 2010 at 05:32 PM Boas Num site que estou a fazer, uso um WISIWYG (tiny mc) para inserir texto numa tabela(no backoffice), texto que posteriormente vai ser mostrado ao utilizador no site em causa. Acontece que estes utilitários criam algum lixo no html e gostaria de o limpar aquando do seu output na página, nomeadamente de tirar os muitos comentários que esta cria, e gostaria de saber que função em php devo usar para retirar os comentários. <?=($linha['texto'])?> Desde já agradeço MCITP-MCTS-MCP Link to comment Share on other sites More sharing options...
fil79 Posted January 8, 2010 at 06:25 PM Author Report Share #304859 Posted January 8, 2010 at 06:25 PM RESOLVIDO consegui usando a seguinte função: <?php function strip_only($str, $tags) { if(!is_array($tags)) { $tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags)); if(end($tags) == '') array_pop($tags); } foreach($tags as $tag) $str = preg_replace('#</?'.$tag.'[^>]*>#is', '', $str); return $str; } $str = '<p style="text-align:center">Paragraph</p><strong>Bold</strong><br/><span style="color:red">Red</span><h1>Header</h1>'; echo strip_only(utf8_encode($linha['descricao']), array('!')); ?> MCITP-MCTS-MCP Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now