note 42260 added to function.substr-replace

From: Date: Mon, 10 May 2004 06:25:00 +0000
Subject: note 42260 added to function.substr-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-69400@lists.php.net to get a copy of this message
The comment by geniusdex is a good one. Short, simple functions are the best. But if the string is not longer than the limit set, NOTHING is returned. Here is the function re-done to always return a string: <?php function dot($str, $len, $dots = "...") { if (strlen($str) > $len) { $dotlen = strlen($dots); $str = substr_replace($str, $dots, $len - $dotlen); } return $str; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.substr-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42260 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42260&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42260&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69400) next »