note 77491 deleted from function.substr by tularis

From: Date: Mon, 31 Dec 2007 10:47:41 +0000
Subject: note 77491 deleted from function.substr by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134609@lists.php.net to get a copy of this message
Note Submitter: ash at atomic-network dot co dot uk ---- I wanted to shorten long words and add '...' so it would turn : 'thisisareallylongnamedfile.jpg' and it shall appear like 'thisisareally...' function short_name($str) { $limit = 35; if(strlen($str > $limit)) { # # If the name is greater than 35 characters # then only display 35 charatcers followed # by ... # return substr($str, 0, $limit) . " ..."; } else { # # Too small; so no need to change # return $str; } }

« previous php.notes (#134609) next »