note 69646 added to function.sprintf

From: Date: Wed, 13 Sep 2006 16:43:56 +0000
Subject: note 69646 added to function.sprintf
Groups: php.notes 
Request: Send a blank email to php-notes+get-117120@lists.php.net to get a copy of this message
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! ---- Server IP: 216.194.113.175 Probable Submitter: 204.119.248.69 ---- Manual Page -- http://www.php.net/manual/en/function.sprintf.php Edit -- https://master.php.net/note/edit/69646 Del: integrated -- https://master.php.net/note/delete/69646/integrated Del: useless -- https://master.php.net/note/delete/69646/useless Del: bad code -- https://master.php.net/note/delete/69646/bad+code Del: spam -- https://master.php.net/note/delete/69646/spam Del: non-english -- https://master.php.net/note/delete/69646/non-english Del: in docs -- https://master.php.net/note/delete/69646/in+docs Del: other reasons-- https://master.php.net/note/delete/69646 Reject -- https://master.php.net/note/reject/69646 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117120) next »