note 69646 deleted from function.sprintf by bobby

From: Date: Wed, 13 Sep 2006 18:31:39 +0000
Subject: note 69646 deleted from function.sprintf by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117123@lists.php.net to get a copy of this message
Note Submitter: andrewteg at yahoo dot com ---- Here is a quick 3-line output that will automatically append a ... to a link that is over a certain length. Handy if you're outputting a list of URLS with links in a confined space. <?php $showChars = 27; $linkText = "<a target='_blank' href='".$data['link']."' title='".$data['link']."'>".substr($data['link'], 0, $showChars).'%s'."</a>&nbsp;&nbsp;"; if (strlen($data['link']) > $showChars) $linkText = sprintf($linkText, '...'); else $linkText = sprintf($linkText, ''); ?> HTH!

« previous php.notes (#117123) next »