orion Posted October 28, 2004 Report Share Posted October 28, 2004 Kaa dabuut gatavu to, ka ievadot teksta laukaa rakstu - man enteri paarveerstos par <br> peecaak??? Vainu vienalga par ko.. Vispaar jau gribu uz BBcode paartaisiit... Bet nu, kaa Enteru dabuut par breiku?? str_replace ,bet kas man jaapaarveersh? Link to comment Share on other sites More sharing options...
Venom Posted October 28, 2004 Report Share Posted October 28, 2004 str_replace("\n",'<br />',$text); vai str_replace("\r",'<br />',$text); bet vispār ir arī funkcija nl2br() Link to comment Share on other sites More sharing options...
Kaklz Posted October 28, 2004 Report Share Posted October 28, 2004 Man patīk šitā: http://3a3-interactive.net/blog.php/post/2003/10/19/68/ Link to comment Share on other sites More sharing options...
Venom Posted October 28, 2004 Report Share Posted October 28, 2004 vēl laba fīča: if (strpos($text,'<')!==false && strpos($text,'>')!==false) $text=htmlspecialchars($text); Link to comment Share on other sites More sharing options...
рпр Posted October 28, 2004 Report Share Posted October 28, 2004 http://lv.php.net/manual/en/function.nl2br.php Link to comment Share on other sites More sharing options...
neonz Posted November 6, 2004 Report Share Posted November 6, 2004 (edited) nl2br() vienīgs neies kopā ar XHTML pie PHP versijas < 4.0.5, jo taisa par <br>, nevis <br /> so, universālāks risinājums tomēr būs $teksts = str_replace("\n", '<br />', $teksts); Savukārt, Venom ieteiktais $teksts = str_replace("\r", '<br />', $teksts) ir galīgi slikti, jo "\r" taisīs tikai Windows paarlūki, uncies sūtīs tikai "\n". Edited November 6, 2004 by neonz Link to comment Share on other sites More sharing options...
john.brown Posted November 9, 2004 Report Share Posted November 9, 2004 $text = preg_replace("/\n|\r\n/","<br>",$text); Link to comment Share on other sites More sharing options...
Venom Posted November 9, 2004 Report Share Posted November 9, 2004 $text = preg_replace("/\n|\r\n/","<br>",$text); tad vismaz $text=str_replace(array("\r\n","\n",'<br>'),'<br />',$text); Link to comment Share on other sites More sharing options...
john.brown Posted November 9, 2004 Report Share Posted November 9, 2004 (edited) Venom, kkāpēc tev tik ļoti nepatīk preg_replace()? Dotajā gadījumā ļauj izmantot pašu regexu sintaksi. $text = preg_replace("/\n|\r\n|<br>/i","<br>",$text); Kaut arī <br> aizvietot ar <br> lielu jēgu neredzu ;) Edited November 9, 2004 by john.brown Link to comment Share on other sites More sharing options...
bubu Posted November 9, 2004 Report Share Posted November 9, 2004 Nevis <BR> par <BR> bet par <BR /> ! xhtml! Un preg_replace šeit nezkāpēc neliekās izdevīgi lietot ātrdarbības dēļ. Tu patestē cik ātri strāda str_replace un preg_replace, tad redzēsi. Link to comment Share on other sites More sharing options...
Kaklz Posted November 9, 2004 Report Share Posted November 9, 2004 Sk. saiti 8 ierakstus uz augšu. Link to comment Share on other sites More sharing options...
john.brown Posted November 9, 2004 Report Share Posted November 9, 2004 (edited) Labi, lai tā būtu. Ja jaaizvieto pāris tūkstoši rindas beigu ar <br>, tad jau protams... Nu, jā. 3,5 reizes lēnāks :) Edited November 9, 2004 by john.brown Link to comment Share on other sites More sharing options...
Faplo Posted November 13, 2004 Report Share Posted November 13, 2004 vai ir iespeja sibolus \" aizvietot ar sibolu " Link to comment Share on other sites More sharing options...
kirils Posted November 13, 2004 Report Share Posted November 13, 2004 stripslashes(). te vispaar kaads manuaali lasa? Link to comment Share on other sites More sharing options...
Recommended Posts