[svn r20573] Added possibility to embed in a <span> to cut() function

skala
Cristian Fasanando 16 years ago
parent 7291a8993b
commit d97dec7e28
  1. 10
      main/inc/lib/text.lib.php

@ -1,4 +1,4 @@
<?php // $Id: text.lib.php 20087 2009-04-24 20:44:55Z juliomontoya $
<?php // $Id: text.lib.php 20573 2009-05-13 00:05:49Z cfasanando $
/*
==============================================================================
Dokeos - elearning and course management software
@ -411,14 +411,18 @@ function date_to_str_ago($date)
}
/**
* This functions cuts a paragraph
* i.e cut('Merry Xmas from Lima',13) = "Merry Xmas fr..."
* i.e cut('Merry Xmas from Lima',13) = "Merry Xmas fr..."
* @param string the text to "cut"
* @param int count of chars
* @param bool Whether to embed in a <span title="...">...</span>
* @return string
* */
function cut($text,$maxchar)
function cut($text,$maxchar,$embed=false)
{
if (strlen($text) > $maxchar) {
if ($embed==true) {
return '<span title="'.$text.'">'.substr($text, 0, $maxchar).'...</span>';
}
return substr($text, 0, $maxchar).'...' ;
} else {
return $text;

Loading…
Cancel
Save