Photoshop cs2 v9.0 Green Chinese PHP Implementation code to truncate text at a character breakpoint

Source: Internet
Author: User
Copy the Code code as follows:


The so-called hyphenation (word break), a place where a word can be broken when changing careers. This function truncates the string at the hyphenation point.
Please acknowledge use of the this Code by including the this header.
function Mytruncate ($string, $limit, $break = ".", $pad = "...") {
Return with no change if string is shorter than $limit
if (strlen ($string) <= $limit)
return $string;
is $break present between $limit and the end of the string?
if (false!== ($breakpoint = Strpos ($string, $break, $limit))) {
if ($breakpoint < strlen ($string)-1) {
$string = substr ($string, 0, $breakpoint). $pad;
}
}
return $string;
}
/***** Example ****/
$short _string=mytruncate ($long _string, 100, ");

The above describes the Photoshop CS2 v9.0 green Chinese version of PHP truncation text at the character breakpoint implementation code, including the Photoshop CS2 v9.0 Green Chinese version of the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.