note 68222 deleted from function.substr by bobby

From: Date: Thu, 14 Sep 2006 18:32:42 +0000
Subject: note 68222 deleted from function.substr by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117193@lists.php.net to get a copy of this message
Note Submitter: kontakt at hundeinfos dot de ---- With your Script, i had a problem in a "while" statement. So i wrote this function. It works very well, without Problems: /** * Findet das letzte Leerzeichen und gibt den String bis * dahin zurück */ function hsSubstr($pvString,$pvMaxLaenge) { $text = substr($pvString,0, $pvMaxLaenge); $posLetzesLeerzeichen = strrpos($text, " "); $rueckgabe = substr($text, 0, $posLetzesLeerzeichen); if (strlen($pvString) > $pvMaxLaenge) { $rueckgabe .= " ..."; } return $rueckgabe; }

« previous php.notes (#117193) next »