I'm trying to truncate this text without lose the HTML tags: Text= <p><span style="font-size: medium;">El biógrafo de Steve Jobs, Walter Isaacson, explica porqué Jobs le pidió que le hiciera su biografía en este artículo de El País.</span></p> <p><span style="font-size: medium;"><span style="font-size: large;">Por qué Steve era distinto.</span></span></p> <p><span style="font-size: medium;"><a href="http://www.elpais.com/ articulo/primer/plano/Steve/era/distinto/elpepueconeg/ 20111009elpneglse_4/Tes">http://www.elpais.com/articulo/primer/plano/ Steve/era/distinto/elpepueconeg/20111009elpneglse_4/Tes</a></span></p> <p><span style="font-size: medium;">Ya se ha publicado la biografía de Steve Jobs escrita por Walter Isaacson "<strong>Steve Jobs by Walter Isaacson</strong>", aquí os dejamos la dirección de amazon donde podeís adquirirla.</span></p> <p><span style="font-size: medium;"><a>http://www.amazon.com/Steve- Jobs-Walter-Isaacson/dp/1451648537</a></span></p>
Then my code is this: <?php $truncateText = $this->Text->truncate( $text, 500, array( 'ending' => '... ', 'exact' => false, 'html' => true ) ); echo $truncateText; ?> And I'm getting this one: <p><span style="font-size: medium;">El biógrafo de Steve Jobs, Walter Isaacson, explica porqué Jobs le pidió que le hiciera su biografía en este artículo de El País.</span></p> <p><span style="font-size: medium;"><span style="font-size: large;">Por qué Steve era distinto.</span></span></p> <p><span style="font-size: medium;"><a href="http://www.elpais.com/ articulo/primer/plano/Steve/era/distinto/elpepueconeg/ 20111009elpneglse_4/Tes">http://www.elpais.com/articulo/primer/plano/ Steve/era/distinto/elpepueconeg/20111009elpneglse_4/Tes</a></span></p> <p><span style="font-size: medium;">Ya se ha publicado la biografía de Steve Jobs escrita por Walter Isaacson "<strong>Steve Jobs by Walter Isaacson</strong>", aquí os dejamos la dirección de amazon donde podeís adquirirla.</span></p> <p><span style="font-size:... </a></span></p> As you can see, the last tags are not well closed (<p><span style="font-size:... </a></span></p>) Because in the text between the tags there are no space (<p><span style="font-size: medium;"><a>http://www.amazon.com/Steve-Jobs-Walter- Isaacson/dp/1451648537</a></span></p>) And the functions goes to cut the phrase in the atributte space of the tag. I dunno if is the correct place for ask this, and I dunno if someone will understand that mistake. Anyway I had construct my own function, is yet in beta phase because is not really flexible in options, but I won't post it since I get a response here, because I want to know if It's error or what is it. So what you think? :S -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php