PHP intercepts data for more than 10 characters. To say, not to change, how to deal with

Source: Internet
Author: User
PHP intercepts data for more than 10 characters .... To say that the lack of change
My database has a field which has six city lengths of more than 100, if the page display, layout is not good row, so want to intercept these six fields of money 10 characters other use .... Said


Do you have any good ideas? And I'm querying the database is all the query data put in the collection


It's a little easier to write.

------Solution--------------------
You can intercept the string when you show it.


------Solution--------------------
If you are afraid of Chinese problems, use mbstring.
------Solution--------------------
discuss

You can intercept the string when you show it.

------Solution--------------------
PHP code
/** * thumbhandler * @access public *//* How to use: Automatic trimming:    The program will cut the largest square from the middle according to the size of the picture, and the thumbnail $t->setsrcimg ("img/test.jpg") according to the target size;    $t->setcuttype (1);//This sentence is OK $t->setdstimg ("tmp/new_test.jpg");    $t->createimg (60,60);    Manual cutting: The program will take the map from the source map according to the specified location $t->setsrcimg ("img/test.jpg"); $t->setcuttype (2 
------solution--------------------
Search Online, many of the
key is to consider the Zhong Wenying character Mix, a Chinese character is two bytes.
------Solution--------------------
Chinese words with this:

function Getsubstr ($s)
{
$substr =strlen ($s) >20? substr (0,20, $str). chr (0). ' ... ': $s;
return $substr;//20 = 10 Chinese
}

If Chinese and English mix, then use ASCII value to determine the number of English to take, how much to take in China
  • /pre>

    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.