Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> szukam skryptu dla tekstu.
-shaut-
post 4.04.2006, 17:43:52
Post #1





Goście







Jezeli takie pytanie juz bylo to sorki.Interesuje mnie czy jest taki skrypt do tekstu,ktory robi cos takiego ze mam np tekst na stronie w pewnym momencie on sie urywa a w rogu pod nim widac napis "wiecej..." po ktorego kliknieciu tekst rozwija sie do konca??,jezeli tak to gdzie ewentualnie moge go znalezc??
Go to the top of the page
+Quote Post
-Guest-
post 15.04.2006, 19:33:25
Post #2





Goście







ten skrypt dziala na zasadzie takiej ,ze pobiera zawartosc wyswietlanego pliku, sprawdza dlugosc, jezeli dluzszy niz(warunek) to dziel. Najprosciej na mysql bylo by to zrobic
Go to the top of the page
+Quote Post
strife
post 15.04.2006, 19:58:05
Post #3





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

Ostrzeżenie: (0%)
-----


Mówisz masz..
  1. <?php
  2.  
  3.  function more( $string, $limit )
  4.  {
  5.  if ( strlen( $string ) > $limit && $_GET[ 'more'] != '1' )
  6.  {
  7.  $find = strpos( substr( $string, $limit, strlen( $string ) ), " " );
  8.  
  9.  $shortText = substr( $string, 0, $limit + $find );
  10.  return $shortText . '... <a href="?more=1">( Czytaj wiecej )</a>';
  11.  }
  12.  else
  13.  {
  14.  // ograniczenie nie bylo potrzebne poniewaz
  15.  // tekst miesci sie w granicach
  16.  return $string;
  17.  
  18.  }
  19.  
  20.  }
  21.  
  22.  $string = "
  23.  Lorem ipsum dolor sit amet consectetuer elit lorem sit Morbi auctor.
  24.  Nulla nulla congue Phasellus id In elit Pellentesque ac Curabitur orci. Quam 
  25.  condimentum laoreet pede cursus Suspendisse dictumst Integer vitae faucibus nec
  26.  Lobortis consectetuer sodales purus convallis urna Vivamus Nam dolor sollicitud
    in 
  27.  consequat. Convallis amet Ut lacus id est dui mauris tortor et egestas. Nam Lor
    em 
  28.  convallis a vitae.";
  29.  
  30.  echo more( $string, 100 );
  31.  
  32. ?>

Pierwszy argument w funkcji to Twój tekst, który chcesz obrobić, a drugi to limit znaków ( skrypt nie ucina wyrazów tylko szuka odstępu ).

Pozdrawiam! smile.gif


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 12.06.2025 - 12:07