Phparclist label: how to add a dot after a truncated character

Source: Internet
Author: User
Phparclist label. how can I add a dot to the end of the screenshot character? dede: arclisttitlelen = 42row = 12} & nbsp; & lt; liclass = 'domainline' & gt; & lt; ahref = & q php arclist label. how can I add a dot after a truncated character?
New Dream
Tag
Dede: arclist titlelen = 42 row = 12}
  • [Field: title/]

  • {/Dede: arclist}
    How can I automatically add... after the length exceeds 42?

    ------ Solution --------------------
    You can also extract the title from the database.
    SELECT id, left (title, 42) as title from table
    ------ Solution --------------------
    Discussion

    You can also extract the title from the database.
    SELECT id, left (title, 42) as title from table

    ------ Solution --------------------
    // Intercept Chinese and English
    Function cut_str ($ sourcestr, $ cutlength = 10, $ etc = '...')
    {
    $ Returnstr = '';
    $ I = 0;
    $ N = 0.0;
    $ Str_length = strlen ($ sourcestr); // Number of bytes of the string
    While ($ n <$ cutlength) and ($ I <$ str_length ))
    {
    $ Temp_str = substr ($ sourcestr, $ I, 1 );
    $ Ascnum = ord ($ temp_str); // Obtain the ASCII code of the $ I character in the string
    If ($ ascnum> = 252) // if the ASCII bit height is 252
    {
    $ Returnstr = $ returnstr. substr ($ sourcestr, $ I, 6); // calculate 6 consecutive characters as a single character according to the UTF-8 encoding specification
    $ I = $ I + 6; // The actual Byte count is 6.
    $ N ++; // string length meter 1
    }
    Elseif ($ ascnum> = 248) // if the ASCII bit height is 248
    {
    $ Returnstr = $ returnstr. substr ($ sourcestr, $ I, 5); // count 5 consecutive characters as a single character according to UTF-8 Encoding Specifications
    $ I = $ I + 5; // The actual Byte count is 5.
    $ N ++; // string length meter 1
    }
    Elseif ($ ascnum> = 240) // if the ASCII bit height is 240
    {
    $ Returnstr = $ returnstr. substr ($ sourcestr, $ I, 4); // count four consecutive characters as a single character according to the UTF-8 encoding specification
    $ I = $ I + 4; // The actual Byte count is 4.
    $ N ++; // string length meter 1
    }
    Elseif ($ ascnum> = 224) // if the ASCII bit height is 224
    {
    $ Returnstr = $ returnstr. substr ($ sourcestr, $ I, 3); // count three consecutive characters as a single character according to the UTF-8 encoding specification
    $ I = $ I + 3; // The actual Byte count is 3.
    $ N ++; // string length meter 1
    }
    Elseif ($ ascnum> = 192) // if the ASCII bit height is 192
    {
    $ Returnstr = $ returnstr. substr ($ sourcestr, $ I, 2); // Count 2 consecutive characters as a single character according to the UTF-8 encoding specification
    $ I = $ I + 2; // The actual Byte count is 2.
    $ N ++; // string length meter 1
    }
    Elseif ($ ascnum> = 65 and $ ascnum <= 90 and $ ascnum! = 73) // except for uppercase letters I
    {
    $ Returnstr = $ returnstr. substr ($ sourcestr, $ I, 1 );
    $ I = $ I + 1; // The actual number of bytes is still counted as 1
    $ N ++; // consider the overall appearance. uppercase letters are counted as a high character.
    }
    Elseif (! (Array_search ($ ascnum, array (37, 38, 64,109,119) ==== FALSE) // %, &, @, m, w characters are 1 character wide
    {
    $ Returnstr = $ returnstr. substr ($ sourcestr, $ I, 1 );
    $ I = $ I + 1; // The actual number of bytes is still counted as 1
    $ N ++; // but considering the overall appearance, the note is counted as a high character
    }
    Else // In other cases, including lower-case letters and halfwidth punctuation marks
    {
    $ Returnstr = $ returnstr. substr ($ sourcestr, $ I, 1 );
    $ I = $ I + 1; // The actual number of bytes is 1.
    $ N = $ n + 0.5; // other lower-case letters and halfwidth punctuation, and half-height character width...
    }
    }
    If ($ I <$ str_length)
    {
    $ Returnstr = $ returnstr. $ etc; // when the length is exceeded, add a ellipsis at the end.
    }
    Return $ returnstr;
    }

    OR

    Select * from tablename substring (title, 1, 10) as t

    ------ Solution --------------------
    There is a piece of code on the homepage. to put it bluntly
    Add your own..., why do you need to add a program?
    PHP code
    {Dede: arclist flag = 'h' limit = '0, 1'} [field: title/]

    [Field: description function = 'CN _ substr (@ me, 110) '/]... [View Full Text]

    {/Dede: arclist}

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.