/**
* Shortens a string for a given number of words
*
* @param string $str
* @param integer $char
* @return string
* @access public
* @since 2002-08-26
* @author Thorsten Rinne <thorsten@phpmyfaq.de
*/
function makeShorterText($str, $char)
{
$str = preg_replace('/\s+/', ' ', $str);
$arrStr = explode(' ', $str);
$shortStr = '';
$num = count($arrStr);
if ($num > $char) {
for ($j = 0; $j <= $char; $j++) {
$shortStr .= $arrStr[$j]." ";
}
$shortStr .= '...';
} else {
$shortStr = $str;
}
return $shortStr;
}
======================================
But in the file FAQ.php,
/**
* This function generates the Top Ten with the mosted viewed records
*
* @return string
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @since 2002-05-07
*/
function getTopTen()
{
$result = $this->getTopTenData(PMF_NUMBER_RECORDS_TOPTEN, 0, $this->language);
if (count($result) > 0) {
$output = '<ol>';
foreach ($result as $row) {
$output .= sprintf('<li><strong>%d %s:</strong><br />',
$row['visits'],
$this->pmf_lang['msgViews']);
$shortTitle = PMF_Utils::makeShorterText(PMF_htmlentities($row['thema'], ENT_QUOTES, $this->pmf_lang['metaCharset']), 8);
$output .= sprintf('<a href="%s">·%s</a></li>',
$row['url'],
$shortTitle);
I am trying many times for the interger 8. It is unavailable.i.e. It never shorten a string(title).
So May you tell me Why?
For the language I am using is Chinese Simplified. Does the function makeShorterText Support the language?
makeShorterText function is unavailible
Moderator: Thorsten
Hi,
with UTF-8 a cahracter isn't just a byte... I'll try to fix this. Please add this issue on http://bugs.phpmyfaq.de
Thanks.
bye
Thorsten
with UTF-8 a cahracter isn't just a byte... I'll try to fix this. Please add this issue on http://bugs.phpmyfaq.de
Thanks.
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist