note 29218 added to function.substr

From: Date: Thu, 06 Feb 2003 10:35:55 +0000
Subject: note 29218 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-43506@lists.php.net to get a copy of this message
Still another fx to split string into token with 'token length', 'separator' and 'replace' string customizable: function CutStr($string, $length, $separator=" ", $replace="\n") { $tmp = explode($separator, $string); $result = ""; $tokencnt = 1; while (list($foo, $value) = each($tmp)) { if (strlen($result.$value) < ($length * $tokencnt)) { $result.=$separator.$value; } else { $result.=$replace.$value; $tokencnt++; } } return $result; } -- http://www.php.net/manual/en/function.substr.php http://master.php.net/manage/user-notes.php?action=edit+29218 http://master.php.net/manage/user-notes.php?action=delete+29218 http://master.php.net/manage/user-notes.php?action=reject+29218

« previous php.notes (#43506) next »