at t noc

Want to know at t noc? we have a huge selection of at t noc information on alibabacloud.com

PHP Summary Generation function (no garbled) _php tips

In the use of the time, you have to generate a summary of the content strip_tags (), of course, you can also add strip_tags () directly to the function, I did not engage, add it myself. Here's the function: Copy Code code as follows: function Cutstr ($string, $length, $charset, $dot) {//character, interception length, character set, end character if (strlen ($string) return $string; } $pre = Chr (1); $end = Chr (1); Protect Special strings $string = str_replace (Array (' ', '

Comparison of discuz and ecshop truncation string functions php _ PHP Tutorial

length of the string is smaller than the length to be intercepted, the system returns// Strlen is used to obtain the length of a string. for example, if the string "happy new year" needs to be intercepted with four Chinese characters,// You must know the number of bytes of these four Chinese characters. Otherwise, the returned string may be "happy new year ..."If (strlen ($ string) Return $ string;}// Convert htmlspecialchars from the original string$ Pre = chr (1 );$ End = chr (1 );$ String =

Comparison of discuz and ecshop truncation string functions in php

number of bytes of these four Chinese characters. Otherwise, the returned string may be "Happy New Year ..."If (strlen ($ string) Return $ string;}// Convert htmlspecialchars from the original string$ Pre = chr (1 );$ End = chr (1 );$ String = str_replace (array ('', '"', '$ Strcut = ''; // initialize the return value// If it is UTF-8 encoded (this judgment is incomplete, it may be utf8)If (strtolower (CHARSET) = 'utf-8 '){// The initial continuous loop pointer $ n, the last digit $ tn, the num

Compare Discuz and Ecshop intercept string functions PHP version _php tips

characters, otherwise the returned string might be "Happy New Year ..." if (strlen ($string) return $string; } Convert Htmlspecialchars in original string $pre = Chr (1); $end = Chr (1); $string = str_replace (Array (' ', ' "'", ' $strcut = '; Initialize return value If it's utf-8 code (this is a little incomplete, it could be UTF8) if (Strtolower (CHARSET) = = ' Utf-8 ') { The initial continuous loop pointer $n, the last number of digits $tn, the number of characters intercepted $

Compare Discuz and Ecshop intercept string functions PHP version _php Tutorial

characters, otherwise the returned string may be "Happy New Year ..." if (strlen ($string) return $string; } Convert the original string to Htmlspecialchars $pre = Chr (1); $end = Chr (1); $string = str_replace (Array (' ', ' ' ', ' $strcut = "; Initialize return value If it's utf-8 code (this is a bit incomplete, it could be UTF8) if (Strtolower (CHARSET) = = ' Utf-8 ') { The initial continuous loop pointer $n, the last word bit number $tn, the number of characters intercepted $

PHP Intercept string

1 /**2 * Method Library-intercept string-"The function author is unknown"3 * @param string $string strings4 * @param int $length character length5 * @param string $dot whether to add after interception ...6 * @param string $charset encoding7 * @return String8 */9 Public functionCUTSTR ($string,$length,$dot= ' ... ',$charset= ' Utf-8 ') {Ten if(strlen($string) $length) { One return $string; A } - $string=Str_replace(Array(' amp; ', ' quot; ', ' Ar

Take the string and use php to intercept the Chinese string-PHP source code

Php does not support Chinese very well. It is a problem to intercept Chinese and English characters in a string, and garbled characters may occur if the string is not properly processed, next we can take the Chinese character string function and handle it well. Php does not support Chinese very well. It is a problem to intercept Chinese and English characters in a string, and garbled characters may occur if the string is not properly processed, next we can take the Chinese character string funct

Using php to intercept a specified length _ PHP Tutorial

Use php to intercept a specified length. PHP language: the code used to copy string based on Chinese characters is as follows: functioncutstr ($ string, $ length, $ dot ...) {if (strlen ($ string) $ length) {return $ string ;}$ prechr (1); PHP language: trim strings based on Chinese characters The code is as follows: Function cutstr ($ string, $ length, $ dot = '...'){If (strlen ($ string) Return $ string;}$ Pre = chr (1 );$ End = chr (1 );$ String = str_replace (array ('', '"', '$ Strcut = ''

PHP Chinese-English mixed string intercept function code _php tutorial

Copy CodeThe code is as follows: function Get_word ($string, $length, $dot = '.. ', $charset = ' GBK ') { if (strlen ($string) return $string; } $string = Str_replace (', ', ' ', ' ' ', ' $strcut = "; if (Strtolower ($charset) = = ' Utf-8 ') { $n = $tn = $noc = 0; while ($n $t = Ord ($string [$n]); if ($t = = 9 | | $t = = 10 | | ($tn = 1; $n + +; $noc + +; } elseif (194 $tn = 2; $n + = 2; $

A detailed _php tutorial on the more general PHP self-built functions in some PHP projects

CodeThe code is as follows: /** * Character interception support UTF8/GBK * @param $string * @param $length * @param $dot */ function Str_cut ($string, $length, $dot = ' ... ') { $strlen = strlen ($string); if ($strlen $string = Str_replace (', ', ' ', ' ' ', ' ' ', ' ' ', ' ' ' ', '-', ' $strcut = "; if (Strtolower (CHARSET) = = ' Utf-8 ') { $length = Intval ($length-strlen ($DOT)-$length/3); $n = $tn = $noc = 0; while ($n

Common PHP code

_ X_FORWARDED_FOR '); } Elseif (getenv ('remote _ ADDR ') strcasecmp (getenv ('remote _ ADDR'), 'Unknown ')){ $ Ip = getenv ('remote _ ADDR '); } Elseif (isset ($ _ SERVER ['remote _ ADDR ']) $ _ SERVER ['remote _ ADDR '] strcasecmp ($ _ SERVER ['remote _ ADDR'], 'Unknown ')){ $ Ip = $ _ SERVER ['remote _ ADDR ']; } Return preg_match ('/[\ d \.] {7, 15}/', $ ip, $ matches )? $ Matches [0]: ''; } Copy content from PHP Code to clipboard /** * UTF-8/GBK character

PHP intercept string Length (mixed string in Chinese and English) _php tutorial

what I used to do. Now let's look at the Chinese truncation function. The code is as follows Copy Code function Moocutstr ($string, $length, $dot = ' ... ') {Global $charset;if (strlen ($string) return $string;}$string = Str_replace (' ', ' ' ', ' $strcut = ";if (Strtolower ($charset) = = ' Utf-8 ') {$n = $tn = $noc = 0;while ($n $t = Ord ($string [$n]);if ($t = = 9 | | $t = = 10 | | ($tn = 1; $n + +; $

PHP character class

= preg_replace ("/ /IsU "," ", $ msg ); 87 $ msg = preg_replace ("/88} 89 if (! $ This-> style) 90 { 91 $ msg = preg_replace ("/ /IsU "," ", $ msg ); 92} 93 # [hyperlink opened in new window] 94 $ msg = preg_replace ("// isU", "", $ msg ); 95 $ msg = preg_replace ("// isU", "", $ msg ); 96 # [replacing the website] 97 $ url = $ this-> get_url (); 98 $ msg = str_replace ($ url, "",

[PHP]-extract strings by length (for UTF-8)

CodeIs to look at the specifications, copy and modify, hope it is perfect... /* **************************************** * ***************************** Func Name: substrex ** Description: * truncated string by length *** parameters: * $ sstring [String]: string * $ nlength [int]: length * $ sdot [String = "... "]: truncation character * $ scharset [String =" UTF-8 "]: encoding ** returns: [bool] Save the result *********************************** ********************************** */ Fu

Php digest generation function (no garbled code)

When using the strip_tags () command, you must add strip_tags () to the function. The following are functions: Copy codeThe Code is as follows: function cutstr ($ string, $ length, $ charset, $ dot) {// character, truncation length, Character Set, and Terminator If (strlen ($ string) Return $ string; } $ Pre = chr (1 ); $ End = chr (1 ); // Protect Special strings $ String = str_replace (array ('', '"', '$ Strcut = ''; If (strtolower ($ charset) = 'utf-8 '){ $ N = $ tn = $

Php source code analysis using the DZX1.5 string truncation function cutstr

Php source code analysis using the DZX1.5 string truncation function cutstr This article describes how to use the DZX1.5 string truncation function cutstr in php source code analysis. Share it with you for your reference. The specific analysis is as follows: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 /** * Function source DZX1.5, file/source/function/function_core.php */ Defin

PHP mixed string truncation Function Code

Copy codeThe Code is as follows: function get_word ($ string, $ length, $ dot = '...', $ charset = 'gbk '){ If (strlen ($ string) Return $ string; } $ String = str_replace (array ('','', '', '"', '$ Strcut = ''; If (strtolower ($ charset) = 'utf-8 '){ $ N = $ tn = $ noc = 0; While ($ n $ T = ord ($ string [$ n]); If ($ t = 9 | $ t = 10 | (32 $ Tn = 1; $ n ++; $ noc ++; } Elseif (194 $ Tn = 2; $ n + = 2; $

Common methods for intercepting strings in PHP

Common methods for intercepting strings in PHP /** * Truncate a string * Params $ string the string to be intercepted * Params $ length: reserved length (number of characters) * Params $ dot: Display excess parts **/ Function _ cutstr ($ string, $ length, $ dot = '...'){ If (strlen ($ string) Return $ string; } $ String = str_replace (array ('', '"', ' $ Strcut = ''; $ N = $ tn = $

Character Interception support UTF8/GBK

/*** Character interception support UTF8/GBK* @param $string* @param $length* @param $dot*/Function Str_cut ($string, $length, $dot ='...'){$strlen = strlen ($string);if($strlen return$string;$string= Str_replace (Array ('','nbsp;','amp;','quot;',''','ldquo;','rdquo;','mdash;','','gt;','middot;','hellip;'), Array ('∵','','','"',"'",'"','"','-','','>','·','... ..'),$string);$strcut ="'; if(Strtolower (CHARSET) = ='Utf-8'){$length = Intval ($length-strlen ($DOT)-$length/3);$n = $tn = $

Use php to extract a specified length

The following describes how to use php to intercept a specified length. For more information about how to use PHP to intercept a string, see the php language. The code is as follows: Function cutstr ($ string, $ length, $ dot = '...'){If (strlen ($ string) Return $ string;}$ Pre = chr (1 );$ End = chr (1 );$ String = str_replace (array ('', '"', '$ Strcut = '';If (strtolower (CHARSET) = 'utf-8 '){$ N = $ tn = $ noc = 0;While ($ n $ T = ord ($ string

Total Pages: 10 1 2 3 4 5 .... 10 Go to: Go

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.