• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Smarty/libs/plugins/modifier.truncate.php

00001 <?php
00026 function smarty_modifier_truncate($string, $length = 80, $etc = '...',
00027                                   $break_words = false, $middle = false)
00028 {
00029     if ($length == 0)
00030         return '';
00031 
00032     if (strlen($string) > $length) {
00033         $length -= strlen($etc);
00034         if (!$break_words && !$middle) {
00035             $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
00036         }
00037         if(!$middle) {
00038             return substr($string, 0, $length).$etc;
00039         } else {
00040             return substr($string, 0, $length/2) . $etc . substr($string, -$length/2);
00041         }
00042     } else {
00043         return $string;
00044     }
00045 }
00046 
00047 /* vim: set expandtab: */
00048 
00049 ?>

Generated on Thu Apr 19 2012 17:01:16 for openbiz by  doxygen 1.7.2