wort ab z.b. 100zeichen trennen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • wort ab z.b. 100zeichen trennen

    Also es gibt ja immer wieder so Idioten die meinen das komplette Design sprengen zu müssen, indem sie das Wort einfach mal über 500Zeichen lang machen.

    So aber nicht mit mir

    Also wie geht das, dass ich z.b. ein Wort nach 100 Zeichen trenne? Also mit Wordwrap komm ich ned weit, weil ich ja ned will das er den String nach so und so viel Zeichen umschalten, sondern ich will des halt nur bei Wörtern haben? Hab mir schon die Array angeschaut, aber da finde ich auch nix passendes.

    Habt ihr nen Vorschlag?

  • #2
    Re: wort ab z.b. 100zeichen trennen

    Original geschrieben von Enzio
    Also es gibt ja immer wieder so Idioten die meinen das komplette Design sprengen zu müssen, indem sie das Wort einfach mal über 500Zeichen lang machen.
    sachen gibt's
    Also wie geht das, dass ich z.b. ein Wort nach 100 Zeichen trenne? Also mit Wordwrap komm ich ned weit, weil ich ja ned will das er den String nach so und so viel Zeichen umschalten, sondern ich will des halt nur bei Wörtern haben?
    bei allem respekt:

    ich befürchte fast, dass ich unfähig war dir zu folgen, gib mir noch ne chance
    Ich denke, also bin ich. - Einige sind trotzdem...

    Kommentar


    • #3
      Code:
      preg_replace(	'#(\w{100,})#e',
      			'wordwrap(\\'\1\\',100,\\'\\',1)',
      			$text);
      Zuletzt geändert von TBT; 04.01.2004, 21:44.
      TBT

      Die zwei wichtigsten Regeln für eine berufliche Karriere:
      1. Verrate niemals alles was du weißt!


      PHP 2 AllPatrizier II Browsergame

      Kommentar


      • #4
        PHP-Code:
        $text preg_replace(    '#(\w{100,})#e',
                    
        'wordwrap('\1',100,' ',1)',
                    
        $text); 
        gibt mir ein

        Code:
        Warning: Unexpected character in input: '\' (ASCII=92) state=1 in E:\Apache Group\Apache2\htdocs\der-enzio2\tutorials\tutorials.php on line 127
        
        Parse error: parse error, unexpected T_LNUMBER in E:\Apache Group\Apache2\htdocs\der-enzio2\tutorials\tutorials.php on line 127
        aus



        @mrhappy

        naja ein solches worttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttt

        hat mal nach 100zeichen beenden bzw. trennen

        EDIT:
        doch keine fehlermeldung aber es geht trotzdem ned
        Zuletzt geändert von Enzio; 04.01.2004, 21:54.

        Kommentar


        • #5
          Original geschrieben von Enzio
          @mrhappy

          naja ein solches worttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttt

          hat mal nach 100zeichen beenden bzw. trennen
          http://www.php.net/wordwrap und die beschreibung durchlesen, vor allem der parameter cut ist interessant
          Ich denke, also bin ich. - Einige sind trotzdem...

          Kommentar


          • #6
            steh grad auf der leitung und wie sieht das dann aus?

            wordwrap($text, 1) oder wie

            Kommentar


            • #7
              es geht so, definitiv !

              $text preg_replace('#(\w{100,})#e','wordwrap(\'\1\',100,\' \',1)',$text);
              TBT

              Die zwei wichtigsten Regeln für eine berufliche Karriere:
              1. Verrate niemals alles was du weißt!


              PHP 2 AllPatrizier II Browsergame

              Kommentar


              • #8
                Original geschrieben von TBT
                es geht so, definitiv !

                $text preg_replace('#(\w{100,})#e','wordwrap(\'\1\',100,\' \',1)',$text);
                angenommen wir machen es mit 10? 100-> 10 oder?

                PHP-Code:
                <?php
                $text 
                "ssssssssssssssssssssssssssssssssssssshhhhhhhhhhhhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiiiittttttttttttttttttttttiiiiiiiiiiiii";
                $text preg_replace('#(\w{10,})#e','wordwrap(\'\1\',10,\' \',1)',$text);
                echo 
                $text;
                ?>
                Parse error: parse error, unexpected T_STRING in E:\Apache Group\Apache2\htdocs\text.php on line 3


                EDIT:

                sorry mein fehler

                Kommentar


                • #9
                  Original geschrieben von Enzio
                  steh grad auf der leitung und wie sieht das dann aus?

                  wordwrap($text, 1) oder wie
                  mit auf der leitung stehen hat das imho nix zu tun, eher mit nicht sorgfältig lesen...

                  cut is laut manual der vierte parameter, wie wär's daher mit
                  PHP-Code:
                  echo wordwrap($text100' '1); 
                  praktisch genauso, wie in Beispiel 2 auf der seite im handbuch
                  Ich denke, also bin ich. - Einige sind trotzdem...

                  Kommentar


                  • #10
                    Hallo!

                    Hier meine Funktion, ht noch kein wordwrap tut aber was es soll :-)

                    PHP-Code:
                    // $string = zu kürzender Text
                    // $charsize = max. länge des Textes
                    // $replace = Zeichen das andeutet das der Text noch weiter geht z.B. [...]
                    function cutstrings($string$charsize$replace)
                    {
                        if(
                    strlen($string) >= $charsize
                        {
                        
                    $string substr($string0$charsize).$replace;
                        }

                        return 
                    $string;

                    Anwendung:
                    PHP-Code:
                    $text "kdsjhjksdhjkhfjksdgfjksehuiefhsdkgkjh";
                    $text cutstrings($text,"10","[...]"); // Ausgabe: kdsjhjksdh[...] 

                    Kommentar


                    • #11
                      wie wärs denn mit chunk_split ? *senfdazugeb*
                      [font=verdana] '][' .... düdeldüdel dü

                      Gruss Socket
                      -----
                      Nein, ich programmiere kein Clan-Script für Dich, nein, auch nicht wenn Deine Schwester gut aussieht!
                      [color=darkblue]
                      Socket Funktionen[/color]
                      [/font]

                      Kommentar

                      Lädt...
                      X