Skip to content

Instantly share code, notes, and snippets.

@kolyadin
Created February 12, 2014 09:35
Show Gist options
  • Save kolyadin/8952480 to your computer and use it in GitHub Desktop.
Save kolyadin/8952480 to your computer and use it in GitHub Desktop.
/**
* @param int $announceLength
* @return null|string
*/
public function getAnnounceFriendly($announceLength = 100){
$announce = trim($this->getAnnounce());
$content = trim($this->getContent());
$output = null;
if (!$announce){
if ($content){
$output = substr($content,0,$announceLength).'...';
}
}else{
$output = substr($announce,0,$announceLength).'...';
}
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment