strlen function
Syntax: strlen (String)
Definition and Usage: the strlen () function returns the length of a string.
substr function
Syntax: substr (string,start,length)
Definition and Usage: the substr () function returns part of a string.
Parameter description
- String: Required. A string that specifies the part to return.
- Start: Required. Specifies where to start the string. Positive number, starting at the specified position of the string, negative, starting at the specified position from the end of the string, 0, starting at the first character in the string.
- Charlist: Optional. Specifies the length of the string to return. The default is until the end of the string. A positive number, returned from the position of the start parameter, and a negative number, returned from the end of the string.
Ord function
Syntax: Ord (String)
Definition and Usage: the Ord () function returns the ASCII value of the first character of a string.
Custom SUBSTR_CN function (can intercept Chinese and English mixed string is not messy) "original"
functionSUBSTR_CN ($str _CN,$length){ if(strlen($str _CN) >$length) { if(Ord($str _CN[$length]) > 128)$length++; $str _CN=substr($str _CN, 0,$length); } return $str _CN;}
Syntax: SUBSTR_CN (string,length)
Definition and Usage: the SUBSTR_CN () function returns a portion of the first character of the string, which is not garbled when it intercepts mixed strings in English and Chinese character.
Parameter description
- String: Required. A string that specifies the part to return.
- Charlist: Must. Specifies the length of the string to return, and returns all characters if the specified length is exceeded.
Strlen, Ord, substr functions--get length, ASCII, and partial strings