Daniel.Dj 0 Denunciar post Postado Julho 4, 2007 eae, td bom?!tô com uma dúvida, eu tenho um sistema de noticias, com um campo textarea p/ digitação dos textos..na hora de exibir o texto, estou utilizando a função nl2br(), mas essa função só substitui o \n por um <br />....o que eu gostaria é que a cada nova linha, adiciona a tag <p> e no final da msm, fechasse a tag </p>...é possível fazer isso?!agradeço desde já! Compartilhar este post Link para o post Compartilhar em outros sites
guma 0 Denunciar post Postado Julho 4, 2007 eae, td bom?!tô com uma dúvida, eu tenho um sistema de noticias, com um campo textarea p/ digitação dos textos..na hora de exibir o texto, estou utilizando a função nl2br(), mas essa função só substitui o \n por um <br />....o que eu gostaria é que a cada nova linha, adiciona a tag <p> e no final da msm, fechasse a tag </p>...é possível fazer isso?!agradeço desde já!E ai tche!!!Tenta usar esta função de formatação de texto..Ve se funciona..function nl2br_indent($string, $indent = 0){ //remove carriage returns $string = str_replace("\r", '', $string); //convert indent to whitespaces if it is a integer. if (is_int($indent)) { //set indent to length of the string $indent = str_repeat(' ', (int)$indent); } //replace newlines with "<br />\n$indent" $string = str_replace("\n", "<br />\n".$indent, $string); //add the indent to the first line too $string = $indent.$string; return $string; }Abração ai velho Compartilhar este post Link para o post Compartilhar em outros sites
Daniel.Dj 0 Denunciar post Postado Julho 4, 2007 valeu guma, mas consegui fazer uma função que eu tava precisando: function paragrafos($txt){ $nTxt = explode("\n", $txt); $txt = ""; for ($i = 0; $i < count($nTxt); $i++) { if (strlen($nTxt[$i]) > 1) { $txt .= "<p>" . htmlentities(str_replace("\r", "", $nTxt[$i]), ENT_COMPAT, "UTF-8") . "</p>\n"; } else { $txt .= "<br />\n"; } } return $txt;} Compartilhar este post Link para o post Compartilhar em outros sites