List Info

Thread: note 77491 added to function.substr




note 77491 added to function.substr
user name
2007-08-31 09:51:47
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;
	}
}
----
Server IP: 194.145.210.3
Probable Submitter: 217.36.72.165
----
Manual Page -- http
://www.php.net/manual/en/function.substr.php
Edit        -- https://master
.php.net/note/edit/77491
Del: integrated  -- h
ttps://master.php.net/note/delete/77491/integrated
Del: useless     -- http
s://master.php.net/note/delete/77491/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/77491/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/77491/spam
Del: non-english -- 
https://master.php.net/note/delete/77491/non-english
Del: in docs     -- http
s://master.php.net/note/delete/77491/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/77491
Reject      -- https://mast
er.php.net/note/reject/77491
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )