Stefan Welscher: Text schneiden bei 100 Zeichen

Beitrag lesen

$text=preg_replace("/^(.{0,100}.*?)(\s.*)?$/","\1",$text);
--> http://de3.php.net/manual/en/function.preg-replace.php
ist eventuell das suchmuster falsch?
weil es wird mir der ganze text angezeigt

Bei mir gehts:

  
<?  
$text="test test test test test test test blah blah blah blah blah blah blah blah perl perl perl perl peeerl perl hello hello hello hello hello hello hello hello hello hello hello lala lala lalala lala lalala";  
  
$text=preg_replace("/^(.{0,100}.*?)(\s.*)?$/","\\1",$text);  
  
print $text."\n\n";  
?>  

-->
php test.php
test test test test test test test blah blah blah blah blah blah blah blah perl perl perl perl peeerl