note 25843 added to function.substr-replace

From: Date: Tue, 08 Oct 2002 20:01:29 +0000
Subject: note 25843 added to function.substr-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-37805@lists.php.net to get a copy of this message
To abbreviate links into '...' if they outreach a certain amount of space; use the preg_replace function instead. For instance you grabbed the headlines of a news site for use on your own page and the lines are to long: asuming the raw material is stored in $unedited; $edited = preg_replace("/(>)([[:print:]]{52,})(<)/e", "'\\1'.substr_replace('\\2 ', '...', '48').'\\3'", $unedited); echo $edited; This will shorten strings longer than 52 characters into 51 characters, with the last being three dots... -- http://www.php.net/manual/en/function.substr-replace.php http://master.php.net/manage/user-notes.php?action=edit+25843 http://master.php.net/manage/user-notes.php?action=delete+25843 http://master.php.net/manage/user-notes.php?action=reject+25843

« previous php.notes (#37805) next »