PHP Source Analysis DZX1.5 string truncation function Cutstr usage
This article describes the PHP source code analysis of the DZX1.5 string truncation function cutstr usage. Share to everyone for your reference. The specific analysis is as follows:
?
123456789101112131415161718192021st2223242526272829303132333435363738394041424344454647484950
/** * Function source DZX1.5, file location/source/function/function_core.php */ Define (' CHARSET ', ' UTF-8 '); function Cutstr
substr instance
$content = ' I love you www.111cn.net ';
$temp = substr ($content, 4);
Echo $temp;
Results:
Love you www.111cn.net '//
Let's take a look at the function from the right.
$temp = substr ($temp, 0,-4);
The results are:
I love www.111c
OK, let's take a look at the Chinese intercept function.
function Moocutstr ($string, $length, $dot = ' ... ') {Global $charset;
if (strlen ($string) return $string;}$string = str_replace (Array (' amp; ', ' quot; ', ' $strcut = ';if (Strto
Often see a novice asked PHP there is no similar to the ASP's left function or right function, to intercept a string on the left-hand side or the beginning of the N-character function. Of course the answer is yes. PHP's substr function can do, but PHP to the two functions into one, here again to share a more excellent function of intercepting strings.
Copy Code code as follows:
/**
* Method Library-intercept string-"This function is unknown"
* @param string $string strings
* @par
, single byte interception mode
function Cn_substr_utf8 ($str, $length, $start =0)
{
if (strlen ($STR) {
Return ";
}
Preg_match_all ("/./su", $str, $ar);
$str = ';
$tstr = ';
In order to be compatible with mysql4.1, the following versions are consistent with the database varchar, where byte interception is used
For ($i =0 isset ($ar [0][$i]); $i + +)
{
if (strlen ($TSTR) {
$tstr. = $ar [0][$i];
}
Else
{
if (strlen ($STR) {
$str. = $ar [0][$i];
}
Else
{
Break
}
}
}
retur
ObjectiveAt present Ttlsa use cloud server, in the case of only one server, want to know the local user access situation, the server is stable operation, use Zabbix, Nagios to monitor appears unreasonable, after many comparisons, decided to use third party monitoring Service (www.jiankongbao.com). Why use third-party monitoring "surveillance Bao"Surveillance Bao such third-party monitoring services exist, f
This name casually up ... the case number equals Ug-noc,noc is also casually up ... numbers of cases +scanf"%d",NOC); theUG =NOC; - while(noc--) $ { the intn,l,r,i,j; thescanf"%d",n); the for(intI=1; i) thescanf"%d",num[i]); -Build_tree (1,1, n); i
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.