note 37156 added to function.substr-replace

From: Date: Wed, 05 Nov 2003 09:40:54 +0000
Subject: note 37156 added to function.substr-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-59928@lists.php.net to get a copy of this message
The easiest way (I think) to add trailing dots after a string which in my case are too long is: <? function dots($num, $string) { if (strlen($string) < $num) { $string = substr_replace($string, '...', '-10', $num); } return $string; } Then on your page do something like: <? echo dots("30" $row['title']); ?> if the string is greater than the specific number it'll replace 3 dots. I hope this helps =) ?> ---- Manual Page -- http://www.php.net/manual/en/function.substr-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37156 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37156&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37156&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#59928) next »