orion Posted October 28, 2004 Report 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?
Venom Posted October 28, 2004 Report Posted October 28, 2004 str_replace("\n",'<br />',$text); vai str_replace("\r",'<br />',$text); bet vispār ir arī funkcija nl2br()
Kaklz Posted October 28, 2004 Report Posted October 28, 2004 Man patīk šitā: http://3a3-interactive.net/blog.php/post/2003/10/19/68/
Venom Posted October 28, 2004 Report Posted October 28, 2004 vēl laba fīča: if (strpos($text,'<')!==false && strpos($text,'>')!==false) $text=htmlspecialchars($text);
рпр Posted October 28, 2004 Report Posted October 28, 2004 http://lv.php.net/manual/en/function.nl2br.php
neonz Posted November 6, 2004 Report 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
john.brown Posted November 9, 2004 Report Posted November 9, 2004 $text = preg_replace("/\n|\r\n/","<br>",$text);
Venom Posted November 9, 2004 Report Posted November 9, 2004 $text = preg_replace("/\n|\r\n/","<br>",$text); tad vismaz $text=str_replace(array("\r\n","\n",'<br>'),'<br />',$text);
john.brown Posted November 9, 2004 Report 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
bubu Posted November 9, 2004 Report 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.
john.brown Posted November 9, 2004 Report 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
Faplo Posted November 13, 2004 Report Posted November 13, 2004 vai ir iespeja sibolus \" aizvietot ar sibolu "
kirils Posted November 13, 2004 Report Posted November 13, 2004 stripslashes(). te vispaar kaads manuaali lasa?
Recommended Posts