PHP arclist tags, how to intercept characters in the back add dot Dot
Beginner's dream weaving.
The label.
Dede:arclist titlelen=42 row=12}
[field:title/]
{/dede:arclist}
How to make beyond the 42 length of the back automatically add ... A little bit.
------Solution--------------------
You can also take the title from the database and intercept it.
SELECT Id,left (title,42) as title from table
------Solution--------------------
discuss
You can also take the title from the database and intercept it.
SELECT Id,left (title,42) as title from table
------Solution--------------------
Implementation of Chinese and English interception
function Cut_str ($sourcestr, $cutlength = ten, $etc = ' ... ')
{
$returnstr = ";
$i = 0;
$n = 0.0;
$str _length = strlen ($SOURCESTR); The number of bytes in the string
while (($n < $cutlength) and ($i < $str _length))
{
$temp _str = substr ($sourcestr, $i, 1);
$ascnum = Ord ($temp _str); Gets the ASCII code of the $i character in the string
if ($ascnum >= 252)//If the ASCII bit is high with 252
{
$returnstr = $returnstr. substr ($sourcestr, $i, 6); According to the UTF-8 encoding specification, the 6 consecutive characters are counted as a single character
$i = $i + 6; The actual byte count is 6
$n + +; String length meter 1
}
ElseIf ($ascnum >= 248)//If the ASCII bit is high with 248
{
$returnstr = $returnstr. substr ($sourcestr, $i, 5); According to the UTF-8 encoding specification, the 5 consecutive characters are counted as a single character
$i = $i + 5; The actual byte count is 5
$n + +; String length meter 1
}
ElseIf ($ascnum >= 240)//If the ASCII bit is high with 240
{
$returnstr = $returnstr. substr ($sourcestr, $i, 4); According to the UTF-8 encoding specification, the 4 consecutive characters are counted as a single character
$i = $i + 4; The actual byte count is 4
$n + +; String length meter 1
}
ElseIf ($ascnum >= 224)//If the ASCII bit is high with 224
{
$returnstr = $returnstr. substr ($sourcestr, $i, 3); According to the UTF-8 encoding specification, the 3 consecutive characters are counted as a single character
$i = $i + 3; The actual byte count is 3
$n + +; String length meter 1
}
ElseIf ($ascnum >= 192)//If the ASCII bit is high with 192
{
$returnstr = $returnstr. substr ($sourcestr, $i, 2); According to the UTF-8 encoding specification, the 2 consecutive characters are counted as a single character
$i = $i + 2; The actual byte count is 2
$n + +; String length meter 1
}
ElseIf ($ascnum >=65 and $ascnum <=90 and $ascnum!=73)//With the exception of the uppercase letter I
{
$returnstr = $returnstr. substr ($sourcestr, $i, 1);
$i = $i + 1; The actual byte count still counts 1
$n + +; But considering overall aesthetics, uppercase letters are counted as a high-level character
}
ElseIf (! ( Array_search ($ascnum, Array (PNS, 109, 119)) = = = FALSE))//%,&,@,m,w character by 1 characters justifies
{
$returnstr = $returnstr. substr ($sourcestr, $i, 1);
$i = $i + 1; The actual byte count still counts 1
$n + +; But considering the overall aesthetics, these notes are counted as a high-level character
}
else//other cases, including lowercase letters and half-width punctuation marks
{
$returnstr = $returnstr. substr ($sourcestr, $i, 1);
$i = $i + 1; Actual byte count of 1
$n = $n + 0.5; The rest of the lowercase letters and half-width punctuation and so on with half a high character justifies ...
}
}
if ($i < $str _length)
{
$returnstr = $returnstr. $ETC; Add ellipses at the end of the length
}
return $returnstr;
}
OR
SELECT * FROM tablename substring (title,1,10) as T
------Solution--------------------
There is a piece of code on the home page, in fact
Add yourself ..., why do you need to add
PHP Code
{dede:arclist flag= ' h ' limit= ' 0,1 '} [field:title/]
[Field:description function= ' Cn_substr (@me, 110) '/] ... [View full text]
{/dede:arclist}